Skip to content

Commit 1baa872

Browse files
committed
fix error print out (in some cases)
1 parent 58ae92a commit 1baa872

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/compiler.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ var compiler = {
205205
compilerOptions: compilerOptions,
206206
files: options['files'] || true,
207207
}
208-
208+
209209
try {
210210
compiler.service = register(tsNodeOptions)
211211
} catch (e) {
@@ -269,11 +269,15 @@ var compiler = {
269269
const errorCode =
270270
'throw ' + 'new Error(' + JSON.stringify(e.message) + ')' + ';'
271271
writeCompiled(errorCode)
272-
// should we really re-register ts-node?
273-
compiler.registerTsNode()
272+
273+
// reinitialize ts-node compilation to clean up state after error
274+
// without timeout in causes cases error not be printed out
275+
setTimeout(() => {
276+
compiler.registerTsNode()
277+
})
274278

275279
if (!compiler.options['error-recompile']) {
276-
return
280+
return
277281
}
278282
const timeoutMs =
279283
parseInt(process.env.TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT) || 5000

0 commit comments

Comments
 (0)