diff --git a/example.ts b/example.ts index a201bd7..2ed0a76 100644 --- a/example.ts +++ b/example.ts @@ -1 +1,11 @@ -console.log('Some .ts code reproducing a bug'); +// Note: the segfault is random, so we have to run this multiple time +import { AsyncLocalStorage } from 'async_hooks'; +const asyncStore = new AsyncLocalStorage; +function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)) } +for(let i = 0; i < 1000; ++i) { + asyncStore.run(() => {}, async() => { + // may need to vary the delay depending on where this is running + await sleep(Math.random() * 100); + process.exit(); + }); +} \ No newline at end of file diff --git a/run.sh b/run.sh index d553b44..024f8fb 100644 --- a/run.sh +++ b/run.sh @@ -6,8 +6,8 @@ n lts # Install package.json dependencies yarn -# Run ts-node -yarn ts-node ./example.ts +# Run ts-node (multiple time to have a chance of catching the random crash) +for n in {1..10000} ; do yarn ts-node ./example.ts || code=$? && break ; done ; sh -c "exit $code" echo "Process exited with code: $?" echo