MCPcopy
hub / github.com/vercel/next.js / destroy

Method destroy

test/lib/next-modes/base.ts:589–637  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

587 }
588
589 public async destroy(): Promise<void> {
590 try {
591 require('console').time('destroyed next instance')
592
593 if (this.isDestroyed) {
594 throw new Error(`next instance already destroyed`, {
595 cause: this.isDestroyed,
596 })
597 }
598 this.isDestroyed = Error()
599 Error.captureStackTrace(this.isDestroyed, this.destroy)
600
601 this.emit('destroy', [])
602 await this.stop().catch(console.error)
603
604 if (process.env.TRACE_PLAYWRIGHT) {
605 await fs
606 .cp(
607 path.join(this.testDir, this.distDir, 'trace'),
608 path.join(
609 __dirname,
610 '../../traces',
611 `${path
612 .relative(
613 path.join(__dirname, '../../'),
614 process.env.TEST_FILE_PATH!
615 )
616 .replace(/\//g, '-')}`,
617 `next-trace`
618 ),
619 { recursive: true }
620 )
621 .catch((e) => {
622 require('console').error(e)
623 })
624 }
625
626 if (!process.env.NEXT_TEST_SKIP_CLEANUP) {
627 // Faster than `await fs.rm`. Benchmark before change.
628 rmSync(this.testDir, { recursive: true, force: true })
629 if (this.tmpRepoDir) {
630 rmSync(this.tmpRepoDir, { recursive: true, force: true })
631 }
632 }
633 require('console').timeEnd(`destroyed next instance`)
634 } catch (err) {
635 require('console').error('Error while destroying', err)
636 }
637 }
638
639 public get url() {
640 return this._url

Calls 10

emitMethod · 0.95
stopMethod · 0.95
timeEndMethod · 0.80
replaceMethod · 0.65
errorMethod · 0.65
requireFunction · 0.50
ErrorFunction · 0.50
timeMethod · 0.45
catchMethod · 0.45
joinMethod · 0.45

Tested by 6

runTestsFunction · 0.36
runTestsFunction · 0.36
sendSmugglingPayloadFunction · 0.36
setupFunction · 0.36
primeFunction · 0.36