File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -150,26 +150,30 @@ fn generate_handlers() -> Result<String> {
150150
151151 let mut handlers = String :: new ( ) ;
152152 for func_name in func_names {
153- if func_name == "fetch" {
153+ if func_name == "fetch" && env :: var ( "RUN_TO_COMPLETION" ) . is_ok ( ) {
154154 handlers += & format ! (
155155 "Entrypoint.prototype.fetch = async function fetch(request) {{
156- try {{
157- let response = exports.fetch(request, this.env, this.ctx);
158- {}
159- }} catch (e) {{
160- handleMaybeCritical(e);
161- throw e;
162- }}
163- }}
156+ let response = exports.fetch(request, this.env, this.ctx);
157+ {}
158+ }}
164159" ,
165160 if env:: var( "RUN_TO_COMPLETION" ) . is_ok( ) {
166- "this.ctx.waitUntil(response);\n return response;"
161+ "this.ctx.waitUntil(response);\n return response;"
167162 } else {
168163 "return response;"
169164 }
170- )
165+ ) ;
166+ } else if func_name == "fetch" || func_name == "queue" || func_name == "scheduled" {
167+ // TODO: Switch these over to https://github.com/wasm-bindgen/wasm-bindgen/pull/4757
168+ // once that lands.
169+ handlers += & format ! (
170+ "Entrypoint.prototype.{func_name} = function {func_name} (arg) {{
171+ return exports.{func_name}.call(this, arg, this.env, this.ctx);
172+ }}
173+ "
174+ ) ;
171175 } else {
172- handlers += & format ! ( "Entrypoint.prototype.{func_name} = exports.{func_name};\n " )
176+ handlers += & format ! ( "Entrypoint.prototype.{func_name} = exports.{func_name};\n " ) ;
173177 }
174178 }
175179
You can’t perform that action at this time.
0 commit comments