Skip to content

Commit

Permalink
add reproducer for TypeStrong/ts-node#1380
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinep92 committed Jun 25, 2021
1 parent 7d52acc commit dd8c11c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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

0 comments on commit dd8c11c

Please sign in to comment.