Skip to content

ESM require('http') breaks SSR in SolidStart #7938

@jchatard

Description

@jchatard

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.49.0

Framework Version

solid-start version 0.2.26

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Clone repro https://github.com/jchatard/sentry-solid
  2. cd sentry-solid
  3. pnpm install
  4. pnpm build
  5. pnpm start

I think if you get SvelteKit working, my guess is that Solid Start would almost identical.

The work done here: #7377

Was probably the way to go, but it was reverted.

Expected Result

  1. Application start and is reachable on port 3000
  2. The example exception is logged to Sentry.io https://github.com/jchatard/sentry-solid/blob/main/src/entry-server.tsx#L24

Actual Result

Server won't start with this output:

file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:26181
    const httpModule = require('http');
                       ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/Users/jchatard/Desktop/sentry-solid/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at Http.setupOnce (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:26181:24)
    at setupIntegration (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:21977:17)
    at file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:21965:7
    at Array.forEach (<anonymous>)
    at setupIntegrations (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:21962:16)
    at NodeClient.setupIntegrations (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:22480:28)
    at Hub.bindClient (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:20241:14)
    at initAndBind (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:22946:7)
    at init (file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:28588:3)
    at file:///Users/jchatard/Desktop/sentry-solid/dist/server.js:30282:1

Node.js v18.9.0
 ELIFECYCLE  Command failed with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions