@@ -153,6 +153,42 @@ describe('generateWrapper with migrations', () => {
153153 expect ( existsSync ( join ( workerDir , '__void_migration_handler.mjs' ) ) ) . toBe ( true ) ;
154154 } ) ;
155155
156+ it ( 'intercepts GET /__void/ready with {ready:true} when wrapper is generated' , async ( ) => {
157+ // Platform's deploy-time readiness probe (packages/api/src/routes/deploy.ts)
158+ // expects a JSON 200 from GET /__void/ready before dispatching migrations.
159+ // Without this, the request falls through to the user's framework handler
160+ // (e.g. SvelteKit -> env.ASSETS), which returns CF's "Assets have not yet
161+ // been deployed to this script." stub during WfP propagation, causing the
162+ // probe to retry until exhaustion.
163+ mkdirSync ( workerDir , { recursive : true } ) ;
164+ writeFileSync (
165+ join ( workerDir , 'index.mjs' ) ,
166+ 'export default { fetch() { return new Response("ok"); } };' ,
167+ ) ;
168+
169+ mkdirSync ( join ( projectRoot , 'db' , 'migrations' ) , { recursive : true } ) ;
170+ writeFileSync (
171+ join ( projectRoot , 'db' , 'migrations' , '001_test.sql' ) ,
172+ 'CREATE TABLE test (id INTEGER PRIMARY KEY);' ,
173+ ) ;
174+
175+ await generateWrapper ( workerDir , 'index.mjs' , projectRoot , {
176+ ...base ,
177+ hasMigrations : true ,
178+ migrationDialect : 'sqlite' ,
179+ } ) ;
180+
181+ const wrapper = readFileSync ( join ( workerDir , 'index.mjs' ) , 'utf-8' ) ;
182+ expect ( wrapper ) . toContain ( '/__void/ready' ) ;
183+ expect ( wrapper ) . toMatch ( / R e s p o n s e \. j s o n \( \s * \{ \s * r e a d y : \s * t r u e \s * \} \s * \) / ) ;
184+ // Must be checked before delegating to original.fetch, otherwise the
185+ // user's framework handler will see the request.
186+ const readyIdx = wrapper . indexOf ( '/__void/ready' ) ;
187+ const originalIdx = wrapper . indexOf ( 'original.fetch' ) ;
188+ expect ( readyIdx ) . toBeGreaterThanOrEqual ( 0 ) ;
189+ expect ( originalIdx ) . toBeGreaterThan ( readyIdx ) ;
190+ } ) ;
191+
156192 it ( 'does not generate migration handler when hasMigrations is false' , async ( ) => {
157193 mkdirSync ( workerDir , { recursive : true } ) ;
158194 writeFileSync (
0 commit comments