ts-node-dev sometimes uses old versions of files for compilation

See original GitHub issue

I am seeing ts-node-dev fail to hot reload files sometimes (even though it notices the file changes and tries to restart according to the output). I don’t have any steps to repro and I’m seeing this randomly every 2-3 days.

It seems different enough from the other issues i’ve seen on here to make its own thread.

I will fully explain my workflow for the most recent case as it may shed some light.

the error looked like:

[INFO] 15:58:29 Restarting: /Users/ryan/app_engine/StoryDoodle/src/server/util/redis.ts has been modified
Using ts-node version 8.0.2, typescript version 3.3.3333
[ERROR] 15:58:32 ⨯ Unable to compile TypeScript:
src/server/cache/JSONCache.ts(5,34): error TS2551: Property 'getAsync' does not exist on type 'IPromisifedRedis'. Did you mean 'hmgetAsync'?
src/server/cache/JSONCache.ts(16,17): error TS2339: Property 'setAsync' does not exist on type 'IPromisifedRedis'.

This is a normal and explainable error but it was only possible with an old file of /util/redis.ts because that’s the only time I had hmgetAsync type defined. In addition, other files which depend on this file are compiling correctly. (they should fail on that version of the file)

My flow:

  1. Make /util/redis.ts with version A (which would not have this error)
  2. Make another file that debends on and works with /util/redis.ts
  3. Modify /util/redis.ts to version B (which should produce this error)
  4. Change my mind and change /util/redis.ts back to version A
  5. Compilation is fine.
  6. Create a new file that depends on /util/redis.ts
  7. Get this error (which could only occur on version B of /util/redis.ts)
  8. Try to resolve error by editing files. This causes visible reloads but error still persists
  9. Restarting ts-node-dev by killing and re-running compiles properly

my command: ts-node-dev --respawn src/server/index.ts OS: MAC OSX 10.14 ts-node-dev version: 1.0.0-pre.32

I can do additional debugging the next time this happens. Just let me know what might help.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:22
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
shayded-execommented, May 7, 2019

Also experiencing this issue. My reproduction steps are basically the same as the issue author.

Here’s the simplified version:

  1. Create file util.ts with a function accepting a string.
  2. Create file test.ts which calls the function in util.ts, but passes in a number instead of a string (which rightfully causes a compilation error).
  3. Modify the function in util.ts to accept a number, which should fix the compile error.
  4. The compile error persists unless test.ts is modified to have different content. Just saving the file again will cause a recompile, but the error still persists.
  5. Restarting ts-node-dev completely fixes the error.

This is extremely annoying to deal with and results in having to restart the compilation quite often, which can take close to a minute.

3reactions
seiyriacommented, Jan 27, 2020

I’ve been running into this too, except fairly frequently (on windows). It seems like every time I change a function signature or add a new file, I need to restart the process or it throws errors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to watch and reload ts-node when TypeScript files change
So all ts file will re-compile to js file and then restart the server. To run while in dev environment, npm run dev....
Read more >
TypeScript Compiling with Visual Studio Code
The workspace version of TypeScript is independent of the version of TypeScript you use to compile your *.ts files. You can just use...
Read more >
Ts-node NPM - npm.io
Older versions of typescript are incompatible with @tsconfig/node16 . In those cases we will use an older default configuration. When in doubt, ts-node ......
Read more >
A Complete Guide to Using TypeScript in Node.js - Better Stack
Executing TypeScript source files directly without compilation. ... This is an important precaution as there are often breaking changes between versions.
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
When a .ts file is compiled as an ES module, ECMAScript import / export syntax is left alone in the .js output; when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found