Skip to content

fix: add diagnostic hints for bundling failures in functions runner#1698

Merged
disintegrator merged 2 commits intomainfrom
fix/functions-import-error-diagnostics
Feb 26, 2026
Merged

fix: add diagnostic hints for bundling failures in functions runner#1698
disintegrator merged 2 commits intomainfrom
fix/functions-import-error-diagnostics

Conversation

@simplesagar
Copy link
Member

@simplesagar simplesagar commented Feb 26, 2026

Summary

  • Adds diagnoseImportError() to the JS function runner entrypoint that pattern-matches known bundling failures and appends actionable hints to the gram_err_003 error message
  • Detects three patterns: sync-request/sync-rpc worker files, native .node addons, and generic relative-path resolution failures
  • Adds 3 tests with fixture files that simulate each failure mode

Context

Users deploying functions that depend on sync-request (or other packages requiring auxiliary worker files) see a generic Unable to import user code: functions.js (gram_err_003) error. The root cause — esbuild can't include standalone worker files in a single-file bundle — is not obvious from the error alone.

Before:

Unable to import user code: functions.js (gram_err_003)

After:

Unable to import user code: functions.js. Your code (or a dependency) uses sync-request/sync-rpc, which requires a worker file that cannot be included in a single-file bundle. Replace it with an async alternative like fetch(). (gram_err_003)

Test plan

  • All 22 existing + new tests pass (vitest run tests/gram-start.test.ts)
  • Verify hint message surfaces correctly in Gram logs UI for a real deployment with a known-bad dependency

🤖 Generated with Claude Code


Open with Devin

…unner

When user code fails to import due to bundling-incompatible packages
(e.g. sync-request requiring xhr-sync-worker.js), the gram_err_003 error
now includes an actionable hint explaining the cause and suggesting a fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simplesagar simplesagar added the bug Something isn't working label Feb 26, 2026
@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment Feb 26, 2026 11:23am

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

🦋 Changeset detected

Latest commit: ee84f75

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

This PR includes changesets to release 1 package
Name Type
function-runners 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

@disintegrator disintegrator marked this pull request as ready for review February 26, 2026 11:21
@disintegrator disintegrator requested a review from a team as a code owner February 26, 2026 11:21
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@disintegrator disintegrator merged commit ee55fa5 into main Feb 26, 2026
30 checks passed
@disintegrator disintegrator deleted the fix/functions-import-error-diagnostics branch February 26, 2026 11:27
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants