Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remix v1.16.1 fail to start ESM app server with tsx watch on Windows #6504

Closed
1 task done
onemen opened this issue May 28, 2023 · 5 comments
Closed
1 task done

Remix v1.16.1 fail to start ESM app server with tsx watch on Windows #6504

onemen opened this issue May 28, 2023 · 5 comments

Comments

@onemen
Copy link

onemen commented May 28, 2023

What version of Remix are you using?

1.16.1

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

With this configuration on Windows Remix fails to start custom server

configuration:

  • remix 1.16.1.
  • serverModuleFormat: 'esm'.
  • one or more ESM dependencies.
  • starting custom app server with tsx watch remix dev -c "tsx watch ./server.js"

You can reproduce this issue by installing @kentcdodds excellent epic-stack

  • npx create-remix@latest --typescript --install --template epicweb-dev/epic-stack
  • installation start the app, it should work without any problem
  • close it.
  • update chalk from version 4.1.2 (CJS) to version 5.2.0 (ESM) npm i -D chalk@5.2.0
  • try to start the app again. it will fail, if you are on Windows

Expected Behavior

App running:

Waiting for app server (f950aa74)
> npm run dev:server
Remix dev server ready

> dev:server
> cross-env MOCKS=true tsx watch --clear-screen=false --ignore "app/**" --ignore "build/**" --ignore "node_modules/**" ./index.js

🔶 Mock server installed
🚀  We have liftoff!
Local:            http://localhost:3000
On Your Network:  http://10.100.102.21:3000
Press Ctrl+C to stop
App server took 3.5s

Actual Behavior

App not running

Waiting for app server (f950aa74)
> npm run dev:server
Remix dev server ready

> dev:server
> cross-env MOCKS=true tsx watch --clear-screen=false --ignore "app/**" --ignore "build/**" --ignore "node_modules/**" ./index.js

🔶 Mock server installed
@onemen
Copy link
Author

onemen commented May 28, 2023

There is an easy fix

updating this code fix the issue

let newAppServer = execa.command(command, {
stdio: "pipe",
env: {
NODE_ENV: "development",
PATH:
bin + (process.platform === "win32" ? ";" : ":") + process.env.PATH,
REMIX_DEV_HTTP_ORIGIN: stringifyOrigin(httpOrigin),
},
// https://github.com/sindresorhus/execa/issues/433
windowsHide: false,
});

    let newAppServer = execa.command(command, {
-     stdio: "pipe",
+     stdio: ['ignore', 'pipe', 'pipe'],
+     shell: true,
      env: {
        NODE_ENV: "development",
        PATH:
          bin + (process.platform === "win32" ? ";" : ":") + process.env.PATH,
        REMIX_DEV_HTTP_ORIGIN: stringifyOrigin(httpOrigin),
      },
      // https://github.com/sindresorhus/execa/issues/433
      windowsHide: false,
    });

EDIT

  • It work also without adding shell: true,
  • it WORK with stdio: ['inherit', 'pipe', 'pipe'] or stdio: ['ignore', 'pipe', 'pipe']
  • it DOES NOT WORK with stdio: ['pipe', 'pipe', 'pipe']
  • using the same script without watch also work. remix dev -c "tsx ./server.js"
  • any colors added to console.log in the server code are stripped out somewhere...
    setting stdio: ['inherit', 'inherit', 'inherit'], fix the color issue

@xHomu
Copy link
Contributor

xHomu commented May 30, 2023

Ah, that explains why I couldn't get tsx watch to work on Windows.

Can confirm the fix solved it!

@onemen onemen changed the title Remix v1.16.1 fail to start custom ESM app server on Windows Remix v1.16.1 fail to start ESM app server with tsx watch on Windows May 31, 2023
@xHomu
Copy link
Contributor

xHomu commented Jun 6, 2023

Seems like Epic Stack resorted to a hack using execa, but this should really be fixed upstream on @remix-run/dev, since this affects everyone who want to use v2 dev server on Windows with tsx.

https://github.com/epicweb-dev/epic-stack/blob/main/server/dev-server.js#L9

xHomu added a commit to xHomu/remix that referenced this issue Jun 6, 2023
MichaelDeBoey pushed a commit to xHomu/remix that referenced this issue Jun 6, 2023
@pcattori
Copy link
Contributor

Closing as this seems to be a bug in tsx, not Remix (#6538 (comment))

@onemen
Copy link
Author

onemen commented Jun 14, 2023

There is already a PR in tsx to fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants