Ts-node: Breaking changes v9.0.0 -> v9.1.0?

Created on 25 Mar 2021  Â·  11Comments  Â·  Source: TypeStrong/ts-node

Expected Behavior

ts-node executes start script and app starts on on port 8080 like it used to.

image

image

Actual Behavior

Strange behavior affecting between the child process and the parent process in our app. The child sends a message, the parent gets the process and sends a message back but the child never gets it.

image

Steps to reproduce the problem

  1. git clone https://github.com/cdr/code-server.git && git checkout jsjoeio/ts-node-repro
  2. yarn && yarn add -D [email protected]
  3. yarn watch
  4. See output in console (app never starts as it should on port 8080)

Minimal reproduction

^See reproduction steps above. If that doesn't suffice or overcomplicates things, feel free to close this issue.

Specifications

  • ts-node v9.1.0
  • node v12.16.1
  • compiler v4.2.3
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "strict": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "forceConsistentCasingInFileNames": true,
    "outDir": "./out",
    "declaration": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "tsBuildInfoFile": "./.cache/tsbuildinfo",
    "incremental": true,
    "typeRoots": ["./node_modules/@types", "./typings", "./test/node_modules/@types"],
    "downlevelIteration": true
  },
  "include": ["./src/**/*.ts"],
  "exclude": ["/test", "/lib", "/ci", "/doc"]
}
  • Operating system and version: macOS Big Sur 11.2.2 (20D80)
  • If Windows, are you using WSL or WSL2?: N/A

Additional Context

The ts-node upgrade came through dependabot in https://github.com/cdr/code-server/pull/2919. Our tests were passing so we thought it was fine to merge. (And now we have a note to write a test for testing our dev workflow, including use of ts-node to prevent this in the future).

After hours of debugging yesterday, my co-maintainer and I realized something in 9.1.0 (tested both 9.1.0 and 9.1.1) started causing issues. We looked at the release notes but didn't see anything unusual.

I figured it could be helpful to report this just in case.

Most helpful comment

Thanks, I'm seeing the same. I see it on node 12.21.0 but not node 15.12.0. I suspect this has something to do with the way node's child_process module sets up the IPC channel.

All 11 comments

Is there a list of binaries which must be globally installed to reproduce this? I'm seeing errors about jq, gulp, and npm-run-all.

These are the errors preventing the reproduction from working as expected. (I assume)
https://github.com/TypeStrong/ts-node-repros/runs/2197059246

Is the reproduction incomplete? Are there additional steps which need to be run?

I'm seeing errors about jq, gulp, and npm-run-all

Apologies! Those are probably required for VS Code.

I spoke to @code-asher and he was able to provide a minimal reproduction setup. Here's the repo:
https://github.com/code-asher/ts-node-repro

Okay so we couldn't reproduce in the minimal reproduction.

One observation: we're both testing using Node v12, but the repro GH action suite uses LTS. If you run Node v14, the issue isn't reproducible (locally).

And in 9.1.0, the tests for 12.16 were removed: https://github.com/TypeStrong/ts-node/pull/1148

So I guess that means this is a bug in Node and not ts-node?

fwiw, I reproduced in GH actions with v12: https://github.com/TypeStrong/ts-node-repros/pull/8

Thanks, I'm seeing the same. I see it on node 12.21.0 but not node 15.12.0. I suspect this has something to do with the way node's child_process module sets up the IPC channel.

I found something interesting. Switching the stdio configuration for the child_process fixes the problem.

    stdio: ['inherit', 'pipe', 'pipe', "ipc"], // <-- this works on node 12
    // stdio: ["ipc"], <--- this exhibits the failure we are seeing on node 12

Do you know, are we allowed to use file descriptor 0 for an IPC channel? If so, how does the child process learn that file descriptor 0 is an IPC channel?

I am also double-checking to be sure that ts-node is properly setting up process.execPath, process.execArgv, process.argv0, and process.argv.

That is a fantastic question...This is waay out of my wheelhouse. I have no idea.

Nice find! I'm not entirely sure why we're using fd 0 for IPC. :thinking: It was probably due to some kind of misunderstanding.

We'll switch to doing it the correct way. I have no idea if IPC is "supposed" to work on fd 0 so I don't know if this is still technically a bug, but this resolves our issue at the very least! Thank you for figuring this out!

Feel free to close this if you'd like! You ended up helping us find the underlying bug in our own codebase and we really appreciate that!

Excellent, glad to hear that. I'm going to keep this open a bit longer
because it might still be a bug on our end, or at least something we can
avoid, if I can figure out what to tweak.

On Mon, Apr 5, 2021 at 3:15 PM Joe Previte @.*> wrote:

Feel free to close this if you'd like! You ended up helping us find the
underlying bug in our own codebase and we really appreciate that!

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/TypeStrong/ts-node/issues/1283#issuecomment-813587350,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAC35OCVLIGXX5QNTFOHVOLTHID6PANCNFSM4ZYK3WSQ
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cevek picture cevek  Â·  4Comments

motss picture motss  Â·  4Comments

dakom picture dakom  Â·  3Comments

max-block picture max-block  Â·  4Comments

cibergarri picture cibergarri  Â·  3Comments