Skip to content

Commit ea76ae5

Browse files
fix: prevent race condition during GraphQL scan when using skipLocalScan with extends
1 parent 38dcc06 commit ea76ae5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/nitro/setup/scanner.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ export async function performGraphQLScan(nitro: Nitro, options: ScanOptions = {}
124124
const scanLocal = shouldScanLocalFiles(nitro)
125125
const extendSources = getExtendSources(nitro)
126126

127+
// Skip rescan when using skipLocalScan with extends
128+
// The dev:start hook triggers rescan but Nitro doesn't await async hooks.
129+
// This causes a race condition where tests/code run before rescan completes.
130+
// Since extend packages don't change during dev, skipping rescan is correct.
131+
if (isRescan && !scanLocal && extendSources?.length) {
132+
return
133+
}
134+
127135
// Step 1: Handle skipLocalScan mode
128136
if (!scanLocal) {
129137
if (!isRescan && !silent) {

tests/e2e/extend-schema-merge.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ describe('extend Schema Merge E2E', () => {
4646
await prepare(nitro)
4747
await build(nitro)
4848

49-
// BUG: After build(), the dev:start hook triggers performGraphQLScan
50-
// which clears and re-populates scanSchemas/scanResolvers.
51-
// During rescan with skipLocalScan:true, extend packages are NOT fully loaded.
52-
5349
devServer = createDevServer(nitro)
5450
const server = await devServer.listen({ port: 0 })
5551
const url = server.url || `http://localhost:${(server as unknown as { port: number }).port}`

0 commit comments

Comments
 (0)