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

Outdated vendored remix types causing typescript errors when instrumenting build #15615

Open
3 tasks done
andrewcohen opened this issue Mar 6, 2025 · 2 comments
Open
3 tasks done
Assignees
Labels
Package: remix Issues related to the Sentry Remix SDK

Comments

@andrewcohen
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/remix

SDK Version

9.5.0

Framework Version

Remix 2.11.2 and 2.15

Link to Sentry event

No response

Reproduction Example/SDK Setup

Steps to Reproduce

The vendored types for remix, particularly ServerBuild are out of date.

Minimal repro:

declare module "virtual:remix/server-build" {
  import type { ServerBuild } from "@remix-run/server-runtime";
  const build: ServerBuild;
  export = build;
}

import * as build from "virtual:remix/server-build";
import { wrapRequestHandler } from "@sentry/cloudflare/request";
import { instrumentBuild } from "@sentry/remix/cloudflare";
import { createRequestHandler } from "@shopify/remix-oxygen";

const instrumentedBuild = instrumentBuild(build);

export default {
  async fetch(
    request: Request,
    env: { [key: string]: any },
    ctx: ExecutionContext,
  ): Promise<Response> {
    return wrapRequestHandler(
      {
        options: {
          enabled: env["SENTRY_ENABLED"],
          dsn: env["SENTRY_DSN"],
          environment: env["SENTRY_ENV"],
        },
        request: request,
        context: ctx,
      },
      async () => {
        const handler = createRequestHandler({
          build: instrumentedBuild,
          mode: import.meta.env["NODE_ENV"],
          getLoadContext: () =>{},
        });
        return handler(req)
      })
  }
}

Expected Result

No type errors

Actual Result

On the call to instrumentBuild

1. Argument of type 'ServerBuild' is not assignable to parameter of type 'ServerBuild | (() => ServerBuild | Promise<ServerBuild>)'.
     Type 'import("/Users/acohen/p/node_modules/.pnpm/@[email protected][email protected]/node_modules/@remix-run/server-runtime/dist/build").ServerBuild' is not assignable to type 'import("/Users/acohen/p/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@open_iuiv3pujvl5pfv746jgqtaej4m/node_modules/@sentry/remix/build/types/utils/vendor/types").ServerBuild'.
       The types of 'entry.module.default' are incompatible between these types.
         Type 'import("/Users/acohen/p/node_modules/.pnpm/@[email protected][email protected]/node_modules/@remix-run/server-runtime/dist/build").HandleDocumentRequestFunction' is not assignable to type 'import("/Users/acohen/p/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@open_iuiv3pujvl5pfv746jgqtaej4m/node_modules/@sentry/remix/build/types/utils/vendor/types").HandleDocumentRequestFunction'.
           Types of parameters 'context' and 'context' are incompatible.
             Type 'EntryContext' is missing the following properties from type 'EntryContext': manifest, routeModules, staticHandlerContext, future, and 2 more. [2345]

On the build argument on the call to createRequestHandler

1. Type 'ServerBuild | (() => ServerBuild | Promise<ServerBuild>)' is not assignable to type 'ServerBuild'.
     Type 'ServerBuild' is missing the following properties from type 'ServerBuild': mode, isSpaMode [2322]
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 6, 2025
@github-actions github-actions bot added the Package: remix Issues related to the Sentry Remix SDK label Mar 6, 2025
@andreiborza
Copy link
Member

Hi @andrewcohen, thanks for filing this.

We'll take a look.

@chargome
Copy link
Member

@onurtemizkan could you take this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: remix Issues related to the Sentry Remix SDK
Projects
Status: No status
Development

No branches or pull requests

5 participants