Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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 · 5 comments
Open
3 tasks done
Assignees
Labels

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/@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]
@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?

@onurtemizkan
Copy link
Collaborator

@andrewcohen, could please check if running instrumentBuild inside wrapRequestHandler resolves this problem?

Docs: https://docs.sentry.io/platforms/javascript/guides/remix/frameworks/hydrogen/#2-instrumenting-your-server

@andrewcohen
Copy link
Author

@onurtemizkan it does not.

As an aside, with instrumentBuild inside of the request handler, we were noticing our workers break from Maximum callstack issues, presumably after re-wrapping the loader too many times. Happy to provide more details in a private setting.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 3, 2025
@onurtemizkan
Copy link
Collaborator

Thanks @andrewcohen, I'm working on updating the vendored types. I'll also try to reproduce the rewrapping issue you mentioned. I'll let you know if I need more details, so we can discuss them on Discord or through email.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

5 participants