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

[VITE] isBot crashes the server in 2.4.1 if isbot is over v4 #8392

Closed
ZeldOcarina opened this issue Dec 28, 2023 · 9 comments · Fixed by #8385 or #8415
Closed

[VITE] isBot crashes the server in 2.4.1 if isbot is over v4 #8392

ZeldOcarina opened this issue Dec 28, 2023 · 9 comments · Fixed by #8385 or #8415
Labels
bug:unverified dependencies Pull requests that update a dependency file

Comments

@ZeldOcarina
Copy link

Reproduction

https://stackblitz.com/edit/remix-run-remix-vwrwea

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M1
    Memory: 198.97 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 120.0.6099.129
    Safari: 17.2.1
  npmPackages:
    @remix-run/dev: ^2.4.1 => 2.4.1 
    @remix-run/eslint-config: ^2.4.1 => 2.4.1 
    @remix-run/express: ^2.4.1 => 2.4.1 
    @remix-run/node: ^2.4.1 => 2.4.1 
    @remix-run/react: ^2.4.1 => 2.4.1 
    vite: ^5.0.10 => 5.0.10

Used Package Manager

npm

Expected Behavior

Server should start with isbot since it's being used as part of entry.server.ts.

Actual Behavior

isbot is being used in entry.server.ts, when upgrading to 2.4.1 and using:

app.all(
  "*",
  createRequestHandler({
    // @ts-expect-error
    build: viteDevServer
      ? () => viteDevServer.ssrLoadModule("virtual:remix/server-build")
      : await import("./build/server/index.js"),
  }),
);

server won't start and crashes with àTypeError: vite_ssr_import_4.default is not a function`

@ZeldOcarina
Copy link
Author

Fix is simple:

image

It just took half an hour to debug, maybe you want to update ìsbot`dependency to latest version and adjust the starter? If it has already been done, sorry for this and pls disregard.

@michaeldebetaz
Copy link
Contributor

michaeldebetaz commented Jan 1, 2024

Thanks for the fix ! Undofortunately, the expected type seems to have changed for the isbot function. In entry.server.tsx, request.headers.get() returns string or null, but isbot() expects string

export default function handleRequest(
  request: Request,
  responseStatusCode: number,
  responseHeaders: Headers,
  remixContext: EntryContext,
) { 
  return isbot(request.headers.get("user-agent") ?? "") // Added " ?? "" "to fix the type error. Hopefully it doesn't break anything.
    ? handleBotRequest(
        request,
...

@brophdawg11 brophdawg11 linked a pull request Jan 2, 2024 that will close this issue
@brophdawg11
Copy link
Contributor

This is resolved by #8385 - you can install isbot@3 in your package.json for now to use with the internal entry.* files.

@brophdawg11 brophdawg11 added the dependencies Pull requests that update a dependency file label Jan 2, 2024
@brophdawg11
Copy link
Contributor

Resolved by #8385 and will be available in the next release

@brophdawg11 brophdawg11 added the awaiting release This issue has been fixed and will be released soon label Jan 2, 2024
@ZeldOcarina
Copy link
Author

nah it's fine I've handled the dependancy import manually!

Copy link
Contributor

github-actions bot commented Jan 9, 2024

🤖 Hello there,

We just published version 2.5.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

1 similar comment
Copy link
Contributor

github-actions bot commented Jan 9, 2024

🤖 Hello there,

We just published version 2.5.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 2.5.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

1 similar comment
Copy link
Contributor

🤖 Hello there,

We just published version 2.5.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue has been fixed and will be released soon label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:unverified dependencies Pull requests that update a dependency file
Projects
None yet
3 participants