File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -342,6 +342,23 @@ const serviceLayers = (input: {
342342 ) ;
343343
344344describe ( "ModelManifest service" , ( ) => {
345+ it . live ( "does not replace newer bundled defaults with an older remote catalog" , ( ) =>
346+ Effect . gen ( function * ( ) {
347+ const service = yield * make ;
348+ assert . deepStrictEqual ( yield * service . refresh , BUNDLED_MODEL_MANIFEST ) ;
349+ const rebooted = yield * make ;
350+ assert . deepStrictEqual ( yield * rebooted . current , BUNDLED_MODEL_MANIFEST ) ;
351+ } ) . pipe (
352+ Effect . scoped ,
353+ Effect . provide (
354+ serviceLayers ( {
355+ prefix : "model-manifest-older-remote-test" ,
356+ response : ( ) => Response . json ( { ...REMOTE_MANIFEST , updatedAt : "2000-01-01T00:00:00Z" } ) ,
357+ } ) ,
358+ ) ,
359+ ) ,
360+ ) ;
361+
345362 it . live ( "prefers a fetched manifest over the bundle and caches it to disk" , ( ) =>
346363 Effect . gen ( function * ( ) {
347364 const service = yield * make ;
Original file line number Diff line number Diff line change @@ -399,6 +399,10 @@ export const make = Effect.gen(function* () {
399399 ) ;
400400 if ( fetched === null ) return manifest ;
401401
402+ if ( manifestUpdatedAtMs ( fetched ) < manifestUpdatedAtMs ( manifest ) ) {
403+ fetchedAtMs = now ;
404+ return manifest ;
405+ }
402406 manifest = fetched ;
403407 fetchedAtMs = now ;
404408 yield * encodeManifestCache ( { fetchedAtMs : now , manifest : fetched } ) . pipe (
You can’t perform that action at this time.
0 commit comments