Skip to content

Commit

Permalink
Fix compile time log after error (#37863)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Jun 21, 2022
1 parent 8e28be0 commit d8bfa7b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/build/output/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ store.subscribe((state) => {
return
}
}

startTime = 0
// Ensure traces are flushed after each compile in development mode
flushAllTraces()
teardownTraceSubscriber()
Expand Down
36 changes: 36 additions & 0 deletions test/development/basic/hmr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,40 @@ describe('basic HMR', () => {
expect(traceData).toContain('client-error')
expect(traceData).toContain('client-success')
})

it('should have correct compile timing after fixing error', async () => {
const pageName = 'pages/auto-export-is-ready.js'
const originalContent = await next.readFile(pageName)

try {
const browser = await webdriver(next.url, '/auto-export-is-ready')
const outputLength = next.cliOutput.length
await next.patchFile(
pageName,
`import hello from 'non-existent'\n` + originalContent
)
expect(await hasRedbox(browser, true)).toBe(true)
await waitFor(3000)
await next.patchFile(pageName, originalContent)
await check(
() => next.cliOutput.substring(outputLength),
/compiled.*?successfully/i
)
const compileTime = next.cliOutput
.substring(outputLength)
.match(/compiled.*?successfully in ([\d.]{1,})\s?(?:s|ms)/i)

let compileTimeMs = parseFloat(compileTime[1])
if (
next.cliOutput
.substring(outputLength)
.match(/compiled.*?successfully in ([\d.]{1,})\s?s/)
) {
compileTimeMs = compileTimeMs * 1000
}
expect(compileTimeMs).toBeLessThan(3000)
} finally {
await next.patchFile(pageName, originalContent)
}
})
})

0 comments on commit d8bfa7b

Please sign in to comment.