Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion example.ts
Original file line number Diff line number Diff line change
@@ -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();
});
}
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down