stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.7k stars 139 forks source link

Process of tsx will never exit after a second run #1468

Open LennardF1989 opened 2 weeks ago

LennardF1989 commented 2 weeks ago

Describe the bug

Using tsx causes the node process to hang when running it for a second time inside a WebContainer. This does not happen on an actual machine.

Link to the blitz that caused the error

https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-8mpkbw?file=index.js,index.ts,package.json

package.json

{
  "name": "bug-tsx",
  "private": true,
  "version": "1.0.0",
  "scripts": {
    "test-1": "node ./index.js",
    "test-2": "tsx ./index.ts"
  },
  "devDependencies": {
    "tsx": "4.15.6"
  }
}

index.js/index.ts

console.log('Hello world!');

Steps to reproduce

  1. npm run test-1 multiple times, there is no issue.
  2. npm run test-2 multiple times, either the second or the third time it will hang and no longer respond anymore.

Open a new terminal, run ps and kill one of the latest node processes using kill -9 PID - the other terminal will go responsive again.

Expected behavior

test-2 behaves in the same way as test-1.

Parity with Local

Screenshots

No response

Platform

Additional context

No response

LennardF1989 commented 2 weeks ago

Did some additional testing:

Here is a list of changes: https://github.com/privatenumber/tsx/compare/v4.8.2..v4.9.0

It probably has to do with something not properly cleaning up after closing the last node process.

I added a test.js to the 4.9.0 StackBlitz (node test.js) and it will not even reach the console.log('Start!'); before the tsx-import.

Compared to node index.js followed by a ps shows no node process, while after running tsx index.ts, it does after which all node-process "stick". They also cannot be killed.