Skip to content

fix(email-service): local sending docs incorrectly say binary attachments require deployment #35525

In progress

Description

@coygeek

Existing documentation URL(s)

What changes are you suggesting?

Update the binary attachment guidance across the local sending guide, Workers API reference, and troubleshooting page to reflect what the current local simulator supports. If older Wrangler versions have a limitation, identify the affected versions so readers can choose the right test path.

Additional information

Summary

Three Email Service pages say the local send_email simulator cannot serialize binary attachment content. The current Wrangler release accepted both an ArrayBuffer and a Uint8Array, returned a message ID for each simulated send, and saved the exact attachment bytes. The docs direct developers to deploy to test an operation they can exercise against a local binding.

Steps to reproduce

  1. In a directory with the Wrangler release listed below, save the configuration as attachment-probe/wrangler.json. The EMAIL binding uses the local simulator, and the sample uses reserved example addresses.
  2. Save the worker as attachment-probe/worker.mjs. It sends the same message without an attachment for the control, with an ArrayBuffer at /buffer, and with a Uint8Array at /view. An HTTP 200 with a message ID indicates that the simulated send succeeded.
  3. Start Wrangler and request the three routes from another terminal. Wait for the two Attachment (attachment): data.bin messages, then use their file paths or the command below to inspect the saved payloads.
Configuration: attachment-probe/wrangler.json
{
  "name": "email-test",
  "main": "worker.mjs",
  "compatibility_date": "2026-11-19",
  "send_email": [{ "name": "EMAIL" }]
}
Reproduction script: attachment-probe/worker.mjs
export default {
  async fetch(request, env) {
    const kind = new URL(request.url).pathname;
    const bytes = Uint8Array.of(0, 255, 65, 127);
    const message = {
      from: "sender@example.com",
      to: "recipient@example.net",
      subject: "Local simulation",
      text: "Control body",
    };
    if (kind === "/buffer" || kind === "/view") {
      message.attachments = [{
        filename: "data.bin",
        type: "application/octet-stream",
        disposition: "attachment",
        content: kind === "/buffer" ? bytes.buffer : bytes,
      }];
    }
    return Response.json(await env.EMAIL.send(message));
  },
};
WRANGLER_SEND_METRICS=false ./node_modules/.bin/wrangler dev --config attachment-probe/wrangler.json --ip 127.0.0.1 --port 18886 --show-interactive-dev-session=false
for route in control buffer view; do
  printf '%s ' "$route"
  curl -sS -w ' HTTP %{http_code}\n' "http://127.0.0.1:18886/$route"
done
for file in attachment-probe/.wrangler/tmp/email/*/email-attachment/*.bin; do
  printf '%s ' "${file##*/}"
  xxd -p "$file"
done

Expected behavior

The sending, API reference, and troubleshooting pages should describe the binary attachment forms that work with local simulation at the tested release. If older releases have a serialization limitation, readers should be able to distinguish those releases from the current behavior.

Actual behavior

The live sending guide says an ArrayBuffer produces a serialization error and tells readers to deploy to test binary attachments. The Workers API reference extends that advice to ArrayBufferView, and Troubleshooting repeats deployment as the solution. The local simulator identified the binding as local, returned HTTP 200 with three distinct message IDs, and saved two binary files with the exact bytes 00ff417f. The attachment-free control produced no attachment file. A separate run using the explicit local-mode CLI flag produced the same successful result for each binary type.

Evidence

  • Expected source: The local sending guide listed above documents local simulation for testing Worker sending before deployment, and the Workers API reference lists both binary types in the public attachment interface.
  • Failure source: The live Binary attachments section, the Workers API reference's local development note, and the Troubleshooting entry contradict the observed HTTP responses and file bytes from the fixture above.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Output from the reduced fixture, with the generated IDs omitted:

control  HTTP 200, distinct messageId
buffer   HTTP 200, distinct messageId, attachment bytes 00ff417f
view     HTTP 200, distinct messageId, attachment bytes 00ff417f

Restoration check

Check the rendered pages together against the same local-only run. A reader should be able to test both binary input forms entirely in the local simulator and inspect the two byte-identical artifacts without being instructed to deploy. The attachment-free control should continue to succeed.

Runtime or environment

Wrangler 4.166.0, bundled Miniflare 5.20261119.0-beta and workerd 1.20261119.1, Node.js 26.13.1, macOS 27.2.1 on arm64. The affected wording also appears in the documentation production branch at 180f559575b69038dc6c7709c9e576fca61d549b. Older releases were outside the verification scope.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: Readers following the published troubleshooting guidance may deploy a Worker unnecessarily to test binary attachments that the current local simulator already supports.
  • Workaround status: available
  • Workaround basis: Use the local binding with either binary input as shown by the byte-for-byte file check.

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions