Skip to content

fix(plugin-embeds): import embed components directly to avoid astro-auto-import in workerd#1840

Draft
marcusbellamyshaw-cell wants to merge 11 commits into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/938-plugin-embeds-workerd-crash
Draft

fix(plugin-embeds): import embed components directly to avoid astro-auto-import in workerd#1840
marcusbellamyshaw-cell wants to merge 11 commits into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/938-plugin-embeds-workerd-crash

Conversation

@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor

What does this PR do?

astro-embed's umbrella entrypoint pulls in @astro-community/astro-embed-integration, which depends on astro-auto-import (no Astro 6/7 support). Astro's Cloudflare dev runner evaluates modules one at a time inside workerd (no exports/module globals), so the CJS leakage anywhere in that chain crashes every route with "exports is not defined" — even though the plugin never uses the integration, only individual embed components. Each component also ships standalone as its own @astro-community/astro-embed-* package with none of that baggage, so importing directly from the sub-package sidesteps the crash entirely.

Closes #938

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (n/a — no UI strings, import path change only)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion (n/a — bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Sonnet 5

Screenshots / test output

packages/plugins/embeds — 9/9 tests pass (new tests/no-astro-embed-integration.test.ts asserts the umbrella package is never imported); pnpm lint:quick clean; pnpm typecheck clean.

Opened as draft: fork already has several open PRs against this repo (non-collaborator open-PR limit).

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3e01424

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

This PR includes changesets to release 1 package
Name Type
@emdash-cms/plugin-embeds 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1840

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1840

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1840

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1840

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1840

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1840

emdash

npm i https://pkg.pr.new/emdash@1840

create-emdash

npm i https://pkg.pr.new/create-emdash@1840

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1840

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1840

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1840

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1840

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1840

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@1840

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1840

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1840

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1840

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1840

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1840

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1840

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1840

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1840

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1840

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1840

commit: 3e01424

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity.

If you're still working on this, please push an update or leave a comment.

@github-actions github-actions Bot added stale and removed stale labels Jul 20, 2026
…uto-import in workerd (emdash-cms#938)

astro-embed's umbrella entrypoint pulls in @astro-community/astro-embed-integration,
which depends on astro-auto-import (no Astro 6/7 support). Astro's Cloudflare dev
runner evaluates modules one at a time inside workerd (no exports/module globals),
so the CJS leakage anywhere in that chain crashes every route with
"exports is not defined" -- even though the plugin never uses the integration,
only individual embed components. Each component also ships standalone as its own
@astro-community/astro-embed-* package with none of that baggage, so importing
directly from the sub-package sidesteps the crash entirely.

Co-Authored-By: Claude Opus 4.8 ultracode <noreply@anthropic.com>
@marcusbellamyshaw-cell
marcusbellamyshaw-cell force-pushed the fix/938-plugin-embeds-workerd-crash branch from 0e8c4c2 to 9475fdf Compare July 22, 2026 03:10
@github-actions github-actions Bot added size/M and removed size/L labels Jul 22, 2026
…itest explicitly

pnpm-lock.yaml was left outdated after the rebase, failing CI's
frozen-lockfile check. Regenerating via workspace-wide vitest:catalog
hits an unrelated pre-existing break in packages/core/package.json
(@vitest/ui ^4.1.10 -> @vitest/pretty-format@4.1.10 not yet published
upstream) -- pinning this package's vitest devDependency explicitly
sidesteps that catalog-wide resolution.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions github-actions Bot added size/XL and removed size/M labels Jul 22, 2026
Prior lockfile regen was reset against the fork's stale main (281
commits behind emdash-cms/emdash), producing a lockfile that wouldn't
match the PR's real merge base. Regenerated against upstream/main
instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions github-actions Bot added size/L and removed size/XL labels Jul 22, 2026
marcusbellamyshaw-cell and others added 3 commits July 22, 2026 13:06
Branch was 11 commits behind; pulling in main to keep the
regenerated lockfile aligned with what CI currently resolves cleanly
elsewhere (main's Query Counts run passes; this branch's did not).
…rd crash

astro-community/astro-embed-bluesky depends on @atproto/api, whose
CommonJS build (transitively multiformats) hits the same
require/exports-global crash in Astro's Cloudflare dev runner as the
astro-embed umbrella package fixed earlier in this PR (emdash-cms#938). Bluesky
posts now render via Bluesky's own oEmbed endpoint (embed.bsky.app)
instead, with no @atproto/api dependency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions github-actions Bot added size/XL and removed size/L labels Jul 23, 2026
@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up fix in this branch: `@astro-community/astro-embed-bluesky` depends on `@atproto/api` -> `multiformats`, both CommonJS, hitting the same workerd `require`/`exports`-not-defined crash this PR already fixes for the `astro-embed` umbrella package. Bluesky posts now render via Bluesky's own oEmbed endpoint (`embed.bsky.app`) instead, with no `@atproto/api` dependency.

The remaining `Measure` (d1 target) and `E2E Cloudflare` failures on this branch are not caused by this PR -- filed separately as #2216. Confirmed via `git diff` that `packages/core`, `packages/cloudflare`, and both fixtures (`fixtures/perf-site`, `e2e/fixture-cloudflare`) are byte-identical to `main`, and neither fixture depends on `plugin-embeds`. Reproduced identically across 3 CI runs, including one after merging latest `main` into this branch.

@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor Author

CI failing 3x in a row now (2026-07-23 06:28, 06:50, and again just now) with the identical signature: Error: http://localhost:4444/_emdash/api/setup/dev-bypass?token=1 did not return ok within 120000ms across Smoke Tests and all 8 E2E Cloudflare shards — the dev server never comes up in time.

Checked for a code correlation and found none: e2e/fixture-cloudflare (what these jobs boot) has zero dependency on the embeds plugin this PR touches, and the pnpm-lock.yaml diff only removes astro-embed/astro-auto-import as intended — no version changes to wrangler/vite/astro/miniflare that could explain a server-boot hang. Two of the three failing runs were on an empty ci: retrigger commit, so it's reproducing independent of the diff.

I don't have rerun permissions on this repo (gh run rerun 403s, needs admin). Could a maintainer kick off a fresh run, or let me know if this points at something real I'm missing?

@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor Author

CI failure on the latest run (5f9de56) — Smoke Tests, Measure, and all 8 E2E Cloudflare jobs failed the same way: the Postgres service container spins for ~16min logging FATAL: role "root" does not exist before timing out. Not related to this diff — checked two other open PRs (#2130, #2214) that ran the same workflow this week and both passed clean. Looks like a transient CI infra flake in the Postgres service container.

I don't have rerun permissions on this repo (fork PR) — could someone with admin access re-run the failed jobs?

Will revert after capturing real crash output; CI currently gives no
visibility into why the dev server never boots (silent since DEBUG unset).
marcusbellamyshaw-cell and others added 2 commits July 25, 2026 22:57
…ella package

Keeping Gist, LinkPreview, Mastodon, Tweet, Vimeo, and YouTube on the
astro-embed umbrella package (matching main) instead of switching them
to individual @astro-community/astro-embed-* dependencies. Adding those
as direct workspace dependencies broke the unrelated e2e/fixture-cloudflare
dev server ("require is not defined" in workerd, before any request is
served) via a pnpm/Vite monorepo dependency-resolution interaction unrelated
to plugin-embeds' own code -- confirmed by bisection with fresh, frozen-
lockfile installs matching CI exactly. The Bluesky fix (dropping
astro-embed-bluesky/@atproto/api for a direct oEmbed call) is unaffected
and unchanged, since it never depended on the umbrella package or the
new individual packages either way.

Trimmed no-astro-embed-integration.test.ts to only the Bluesky-specific
assertions, since the other components now intentionally go back through
astro-embed. Dropped the stale-donkeys-jump changeset describing the
now-reverted migration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@emdash-cms/plugin-embeds crashes Astro 6 + Cloudflare dev runner with "exports is not defined" (prod build is fine)

1 participant