Skip to content

o11y POC for Express - #13963

Merged
jeffsee55 merged 45 commits into
mainfrom
rolldown-2
Sep 23, 2025
Merged

jeffsee55 merged 45 commits into
mainfrom
rolldown-2

Conversation

@jeffsee55

@jeffsee55 jeffsee55 commented Sep 19, 2025 •

Copy link
Copy Markdown
Contributor

This adds support for an experimental builder that does app introspection on the Express instance. It can used with an env var VERCEL_EXPERIMENTAL_EXPRESS_BUILD=1. It provides route-level o11y so when you're looking at your logs you can see the routes served

Screenshot 2025-09-19 at 3 32 30 PM

Key differences:

  • No longer calls into the @vercel/node builder. Uses rolldown instead.
    • It does NOT check types at this time.
    • It still doesn't bundle, it just transforms the files in-place. And doesn't process node_modules aside from using NFT for them, as we do in the node builder.
    • Using rolldown mostly because what we need to do here has diverged from the @vercel/node logic sufficiently and starting from scratch is a bit easier for now. And it had some wins over esbuild for being able to avoid bundling.
    • It has the added benefit of working with tsconfig paths, missing extensions on relative imports, and code that mixes esm/cjs syntax.
    • NFT is run on the compiled result instead of source, it wasn't resolving tsconfig path imports like @/my-lib or imports with missing file extensions, but running it against the compiled code seems to work nicely.
  • Writes result to the filesystem, whereas with the node builder everything is in memory until writeBuildResult.
  • Invokes the compiled code with a monkey-patched version of express that emits app metadata like routes, static folders and view folders.
  • Uses the build output version 2, there's some messy code in the build command to handle this because the @vercel/express package currently uses version 3
  • Does not support vc dev at the moment. Use srvx!

Explanation

The gist of the POC is that we need to extract info from the express instance, so we compile the source code, monkey-patch express with a wrapper function that exports the app's metadata, invoke the code with a child process and then use the metadata add routes to the build output and then clean up the monkey-patch code.

NOTE: the introspection logic is basic, it doesn't process sub-routes. There's some work to the Express router that will make this easier for v5, and for v4 the logic will look different but AFAIK it's easier to do there.

Before we can really use this as the main path forward

We need to validate this approach, it's kind of a hack but does give us some nice improvements. The change to using rolldown is arguably not necessary, we might want to continue to use the node builder logic to reduce friction.

@changeset-bot

changeset-bot Bot commented Sep 19, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 795704b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/express Patch
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jeffsee55 jeffsee55 changed the title wip WIP o11y POC for Express Sep 19, 2025
Comment thread packages/express/src/introspection.ts Resolved
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 19, 2025 •

Copy link
Copy Markdown
Contributor

🧪 Test Strategy

Comparing: 6d823dd → b156117 (view diff)

Strategy: Infrastructure changes detected - running ALL tests

⚠️ Infrastructure or core utility changes were detected, so we're running the full test suite to ensure integration between packages is properly tested.

Affected packages (30): All packages will be tested

Includes:

  1. @vercel-internals/get-package-json
  2. @vercel/build-utils
  3. @vercel/client
  4. @vercel/detect-agent
  5. @vercel/edge
  6. @vercel/error-utils
  7. @vercel/express
  8. @vercel/firewall
  9. @vercel/frameworks
  10. @vercel/fs-detectors
  11. @vercel/functions
  12. @vercel/gatsby-plugin-vercel-builder
  13. @vercel/go
  14. @vercel/h3
  15. @vercel/hono
  16. @vercel/hydrogen
  17. @vercel/next
  18. @vercel/node
  19. @vercel/oidc
  20. @vercel/oidc-aws-credentials-provider
  21. @vercel/python
  22. @vercel/redwood
  23. @vercel/related-projects
  24. @vercel/remix-builder
  25. @vercel/routing-utils
  26. @vercel/ruby
  27. @vercel/static-build
  28. @vercel/static-config
  29. examples
  30. vercel

E2E Tests: All e2e tests will run


This comment is automatically generated based on the affected testing strategy

@jeffsee55
jeffsee55 enabled auto-merge (squash) September 22, 2025 22:34
jeffsee55 and others added 2 commits September 23, 2025 10:51
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
@jeffsee55
jeffsee55 merged commit 353eca5 into main Sep 23, 2025
@jeffsee55
jeffsee55 deleted the rolldown-2 branch September 23, 2025 19:50
jeffsee55 pushed a commit that referenced this pull request Sep 23, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Patch Changes

- Add experimental o11y support for express when
`VERCEL_EXPERIMENTAL_EXPRESS_BUILD=1`
([#13963](#13963))

- Updated dependencies
\[[`353eca54fe2a892ca04fa66a1665d89d7a722a7a`](353eca5)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Add experimental o11y support for express when
`VERCEL_EXPERIMENTAL_EXPRESS_BUILD=1`
([#13963](#13963))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 795704b5 Deployed Sep 23, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants