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

Cannot find port when running listen with IPX #135

Open
sifferhans opened this issue Oct 31, 2023 · 1 comment
Open

Cannot find port when running listen with IPX #135

sifferhans opened this issue Oct 31, 2023 · 1 comment

Comments

@sifferhans
Copy link

Environment

MacBook Pro M1 Pro 32GB
macOS Sonoma 14.0

IPX: 2.0.0
Node: 18.18.0

Reproduction

https://codesandbox.io/p/sandbox/listhen-repro-pxcqwx

Describe the bug

When running listen with only a simple IPX node server, listen cannot find port 3000 for some reason.
It first starts at port 3000 but then gets an error saying it cannot find an exported entrypoint in index.ts. It then starts again on port 3001, because it says port 3000 is not available.

CleanShot 2023-10-31 at 14 49 18

Additional context

No response

Logs

$ listhen -w ./index.ts

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

📁 Serving static files from ./public                       listhen 1:47:03 PM
🚀 Loading server entry ./index.ts                          listhen 1:47:03 PM

[listhen 1:47:04 PM]  ERROR  Make sure your server entrypoint exports a compatible handler, handle, app or default function export.



[get-port] Unable to find an available port (tried 3000-3100 on any host). Using alternative port 3001

  ➜ Local:    http://localhost:3001/
  ➜ Network:  use --host to expose

👀 Watching ./ for changes                                  listhen 1:47:04 PM
@markthree
Copy link
Contributor

markthree commented Jan 20, 2024

I guess listen -w occupies a port, and the module occupies a port internally, so it jumps to 3001.

According to the README of ipx and listen, if using listen -w, we should try to use the following code 👇

import { createIPX, ipxFSStorage, createIPXH3App } from "ipx";

const ipx = createIPX({
  storage: ipxFSStorage({ dir: "./public" }),
});

export const app = createIPXH3App(ipx);

Finally, based on my long-term use, codesanbox may reserve ports, so try to use the local environment for testing.

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

No branches or pull requests

2 participants