Skip to content

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

@andrewcohen

Description

@andrewcohen

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/@remix-run+server-runtime@2.11.2_typescript@5.7.2/node_modules/@remix-run/server-runtime/dist/build").ServerBuild' is not assignable to type 'import("/Users/acohen/p/node_modules/.pnpm/@sentry+remix@9.5.0_@opentelemetry+context-async-hooks@1.30.1_@opentelemetry+api@1.9.0__@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/@remix-run+server-runtime@2.11.2_typescript@5.7.2/node_modules/@remix-run/server-runtime/dist/build").HandleDocumentRequestFunction' is not assignable to type 'import("/Users/acohen/p/node_modules/.pnpm/@sentry+remix@9.5.0_@opentelemetry+context-async-hooks@1.30.1_@opentelemetry+api@1.9.0__@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]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions