| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 58eaf3f commit e1c6f46
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -547,7 +547,7 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 547 | 547 | ` | |
| 548 | 548 | import {MessageChannel} from 'node:worker_threads'; | |
| 549 | 549 | import {register} from 'node:module'; | |
| 550 | - import {setTimeout} from 'node:timers/promises'; | ||
| 550 | + import {once} from 'node:events'; | ||
| 551 | 551 | const {port1, port2} = new MessageChannel(); | |
| 552 | 552 | port1.on('message', (msg) => { | |
| 553 | 553 | console.log('message', msg); | |
@@ -558,8 +558,12 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 558 | 558 | ); | |
| 559 | 559 | console.log('register', result); | |
| 560 | 560 | ||
| 561 | - await import('node:os'); | ||
| 562 | - await setTimeout(99); // delay to limit flakiness | ||
| 561 | + const timeout = setTimeout(() => {}, 2**31 - 1); // to keep the process alive. | ||
| 562 | + await Promise.all([ | ||
| 563 | + once(port1, 'message').then(() => once(port1, 'message')), | ||
| 564 | + import('node:os'), | ||
| 565 | + ]); | ||
| 566 | + clearTimeout(timeout); | ||
| 563 | 567 | port1.close(); | |
| 564 | 568 | `, | |
| 565 | 569 | ]); | |
@@ -655,10 +659,10 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 655 | 659 | ]); | |
| 656 | 660 | ||
| 657 | 661 | assert.strictEqual(stderr, ''); | |
| 658 | - assert.deepStrictEqual(stdout.split('\n'), [ 'result 1', | ||
| 659 | - 'result 2', | ||
| 660 | - 'hooks initialize 1', | ||
| 662 | + assert.deepStrictEqual(stdout.split('\n'), [ 'hooks initialize 1', | ||
| 663 | + 'result 1', | ||
| 661 | 664 | 'hooks initialize 2', | |
| 665 | + 'result 2', | ||
| 662 | 666 | '' ]); | |
| 663 | 667 | assert.strictEqual(code, 0); | |
| 664 | 668 | assert.strictEqual(signal, null); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,8 @@ | |||
| 1 | + import { writeFileSync } from 'node:fs'; | ||
| 2 | + | ||
| 1 | 3 | let counter = 0; | |
| 2 | 4 | ||
| 3 | 5 | export async function initialize() { | |
| 4 | - counter += 1; | ||
| 5 | - console.log('hooks initialize', counter); | ||
| 6 | + writeFileSync(1, `hooks initialize ${++counter}\n`); | ||
| 6 | 7 | return counter; | |
| 7 | 8 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments