Skip to content

Conversation

@sragss
Copy link
Contributor

@sragss sragss commented Jan 17, 2026

Background
The @x402/next (and other HTTP middleware) packages use dynamic imports with /* webpackIgnore: true */ for the bazaar extension:

bazaarPromise = import(/* webpackIgnore: true */ "@x402/extensions/bazaar")

This fails on serverless platforms (e.g., Vercel) because:

  1. webpackIgnore tells the bundler to resolve the module at runtime
  2. Serverless functions only have access to bundled code, not node_modules
  3. The dynamic import fails with ERR_MODULE_NOT_FOUND

From Vercel:

Failed to load bazaar extension: Error: Cannot find package '@x402/extensions' imported from /var/task/.next/server/chunks/_453aea9d._.js
    at ignore-listed frames {
  code: 'ERR_MODULE_NOT_FOUND'
}

Solution
Update all HTTP middleware packages (next, express, hono) to skip the dynamic import when the extension is pre-registered

Users on serverless platforms can now pre-register the bazaar extension using a static import:

import { bazaarResourceServerExtension } from "@x402/extensions/bazaar"

const server = new x402ResourceServer(facilitator)
server.registerExtension(bazaarResourceServerExtension)
  • Static imports are bundled correctly
  • hasExtension("bazaar") returns true
  • Dynamic import is skipped entirely
  • No runtime errors

Users on traditional servers (where node_modules is available) see no change in behavior.

Add `hasExtension()` method to x402ResourceServer to check if an
extension is already registered. Update all HTTP middleware packages
(next, express, hono) to skip the dynamic import of @x402/extensions/bazaar
when the extension has been pre-registered.

This fixes deployment issues on serverless platforms (e.g., Vercel)
where dynamic imports with `webpackIgnore: true` fail because
node_modules are not available at runtime. Users can now pre-register
the bazaar extension using a static import:

```typescript
import { bazaarResourceServerExtension } from "@x402/extensions/bazaar"

const server = new x402ResourceServer(facilitator)
server.registerExtension(bazaarResourceServerExtension)
```

The static import is bundled correctly, and with this change the
middleware skips the dynamic import entirely, avoiding the runtime error.
@cb-heimdall
Copy link

cb-heimdall commented Jan 17, 2026

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link

vercel bot commented Jan 17, 2026

@sragss is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added typescript sdk Changes to core v2 packages labels Jan 17, 2026
Copy link
Contributor

@phdargen phdargen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch @sragss and thanks a lot for the fix!

@phdargen phdargen self-assigned this Jan 17, 2026
@phdargen phdargen merged commit 7012119 into coinbase:main Jan 17, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk Changes to core v2 packages typescript

Development

Successfully merging this pull request may close these issues.

3 participants