Skip to content

Regenerate email bindings with per-mono generics - #1058

Open
logan-gatlin wants to merge 1 commit into
flagship-per-mono-genericsfrom
generics-per-mono-everything
Open

Regenerate email bindings with per-mono generics#1058
logan-gatlin wants to merge 1 commit into
flagship-per-mono-genericsfrom
generics-per-mono-everything

Conversation

@logan-gatlin

@logan-gatlin logan-gatlin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Enable experimental per-monomorphization generics for both generated Email binding copies
  • Regenerate Email APIs with JsStringLike parameters and JsString getter variants
  • Advance ts-gen to include the typed-array dictionary-helper ABI fix

Stack

Validation

  • cargo test -p worker --target wasm32-unknown-unknown
  • cargo check -p worker-sys -p worker --target wasm32-unknown-unknown
  • Email and Flagship Vitest suites pass; full suite passed 150 tests with one unrelated R2 timeout that passed on targeted rerun

@logan-gatlin logan-gatlin changed the title feat(flagship): support generic mono email bindings Regenerate typescript bindings with per-mono generics Sep 8, 2026
@codspeed-hq

codspeed-hq Bot commented Sep 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 2 untouched benchmarks


Comparing generics-per-mono-everything (d3ac101) with main (78dc0cd)1

Open in CodSpeed

Footnotes

  1. No successful run was found on flagship-per-mono-generics (8be4ab2) during the generation of this report, so main (78dc0cd) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@logan-gatlin

Copy link
Copy Markdown
Collaborator Author

Oh I thought ts-gen was used for way more than just email and flagship, I should probably just fold this into the first PR

@logan-gatlin
logan-gatlin force-pushed the generics-per-mono-everything branch from 7167988 to 1e5edb4 Compare September 8, 2026 19:50
@logan-gatlin logan-gatlin changed the title Regenerate typescript bindings with per-mono generics Regenerate email bindings with per-mono generics Sep 8, 2026
@logan-gatlin
logan-gatlin force-pushed the flagship-per-mono-generics branch from 76e555a to 4437aac Compare September 8, 2026 20:16
@logan-gatlin
logan-gatlin force-pushed the generics-per-mono-everything branch from 1e5edb4 to 795696c Compare September 8, 2026 20:16
@logan-gatlin
logan-gatlin force-pushed the flagship-per-mono-generics branch from 4437aac to b5eefaa Compare September 8, 2026 20:23
@logan-gatlin
logan-gatlin force-pushed the generics-per-mono-everything branch from 795696c to 0a5827b Compare September 8, 2026 20:24
@logan-gatlin
logan-gatlin force-pushed the flagship-per-mono-generics branch from b5eefaa to 8be4ab2 Compare September 8, 2026 22:25
@logan-gatlin
logan-gatlin force-pushed the generics-per-mono-everything branch from 0a5827b to d3ac101 Compare September 8, 2026 22:25

@guybedford guybedford left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified locally: chomp build:types is a clean no-op on this commit (deterministic, and the ts-gen bump leaves flagship.rs unchanged), send_email.spec.ts + flagship.spec.ts pass, and the glue collapses (&str, &str, String) into a single new EmailMessage(...) import as expected.

Requesting changes for two things:

  1. worker-sys/src/types/email.rs is a dead file — it is never declared (worker-sys/src/types.rs has no mod email;), it was left behind by #996. Rather than adding a second ts-gen invocation to keep regenerating it, delete the file and drop the second command.

  2. This is the first per-mono regeneration of an already-released binding, and it breaks &String callers. JsStringLike is sealed to String, &str, JsString, &JsString; with a concrete &str parameter &String deref-coerced, through a generic bound it does not:

error[E0277]: the trait bound `&std::string::String: JsStringLike` is not satisfied
  --> EmailMessage::new(s, s, s)   // s: &String

The example diffs in this PR (new(&to, &from, &raw) -> new(to, from, raw)) are exactly that break, and worker::EmailMessage::new, SendEmailBuilderBuilder::text(&body) etc. are public API. This needs a wasm-bindgen PR adding IntoWasmAbi / OptionIntoWasmAbi / JsStringLike for &String (delegating to &str) before we regenerate existing bindings with per-mono generics, otherwise every binding we convert will hit the same regression. This PR should then land on top of that submodule bump with the example changes reverted.

Comment thread chompfile.toml
--export cloudflare:email \
--external "Env=crate::Env" \
--external "ExecutionContext=crate::Context"
ts-gen --input types/email.d.ts --output worker-sys/src/types/email.rs \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

worker-sys/src/types/email.rs isn't wired into worker-sys at all (no mod email; in worker-sys/src/types.rs) — it's an orphan from #996. Delete the file instead of adding this second invocation.

.map_err(|e| Error::RustError(e.to_string()))?;

let reply = email::EmailMessage::new(&to, &from, &raw)?;
let reply = email::EmailMessage::new(to, from, raw)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This change is required because &String no longer satisfies the generic bound — which is a source break for downstream users of the released EmailMessage::new. See the review summary: this needs JsStringLike for &String upstream in wasm-bindgen first, after which this diff (and the send-email / test ones) can be reverted.

pub fn set_filename(this: &EmailAttachment, val: &str);
pub fn set_filename<S: ::wasm_bindgen::JsStringLike>(this: &EmailAttachment, val: S);
#[wasm_bindgen(method, getter, js_name = "type")]
pub fn type_(this: &EmailAttachment) -> String;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit (ts-gen): type__js_string has a double underscore from type_ + _js_string. The keyword-escape underscore should be stripped before suffixing so this becomes type_js_string.

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