Skip to content

V2 fallback service type field is always "import", even for require() calls #6475

@jamesopstad

Description

@jamesopstad

Description

When using the V2 fallback service protocol (enabled by new_module_registry), the type field in the JSON request body is always "import", even when the module was loaded via require().

Expected Behavior

The type field should reflect how the module was requested:

  • "import" - Static or dynamic ES module import
  • "require" - CommonJS-style require() call
  • "internal" - Import originated from inside the runtime

Actual Behavior

The type field is always "import", regardless of how the module was loaded.

Root Cause

In src/workerd/server/workerd-api.c++, the V2 fallback callback hardcodes ImportType::IMPORT:

Reproduction

https://github.com/jamesopstad/v2-fallback-service-require-repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions