Skip to content

Commit

Permalink
fix: don't use WorkerEntrypoint env or ctx in email handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisDuarte1 committed Aug 26, 2024
1 parent c245ea8 commit a72c76b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions worker-build/src/js/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ class Entrypoint extends WorkerEntrypoint {
return await imports.scheduled(event, this.env, this.ctx)
}

async email(message) {
return await imports.email(message, this.env, this.ctx)
// For some reason, email events doesn't seem to use WorkerEntrypoint so we get the env and ctx from
// from the function itself.
async email(message, _env, _ctx) {
return await imports.email(message, _env, _ctx)
}
}

Expand Down
2 changes: 1 addition & 1 deletion worker-macros/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn expand_macro(attr: TokenStream, item: TokenStream) -> TokenStream {
&(input_fn.sig.ident.to_string() + "_email_glue"),
input_fn.sig.ident.span(),
);
let wrapper_fn_ident = Ident::new("email", input_fn.sig.ident.span());
let wrapper_fn_ident = Ident::new("email_handler", input_fn.sig.ident.span());
// rename the original attributed fn
input_fn.sig.ident = input_fn_ident.clone();

Expand Down

0 comments on commit a72c76b

Please sign in to comment.