File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ export { wasmModule };
1010
1111class Entrypoint extends WorkerEntrypoint {
1212 async fetch ( request ) {
13- return await imports . fetch ( request , this . env , this . ctx )
13+ let response = imports . fetch ( request , this . env , this . ctx ) ;
14+ $WAIT_UNTIL_RESPONSE
15+ return await response ;
1416 }
1517
1618 async queue ( batch ) {
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const OUT_DIR: &str = "build";
1818const OUT_NAME : & str = "index" ;
1919const WORKER_SUBDIR : & str = "worker" ;
2020
21+ const SHIM_TEMPLATE : & str = include_str ! ( "./js/shim.js" ) ;
22+
2123const WASM_IMPORT : & str = r#"let wasm;
2224export function __wbg_set_wasm(val) {
2325 wasm = val;
@@ -54,7 +56,13 @@ pub fn main() -> Result<()> {
5456 use_glue_import ( ) ?;
5557
5658 write_string_to_file ( worker_path ( "glue.js" ) , include_str ! ( "./js/glue.js" ) ) ?;
57- write_string_to_file ( worker_path ( "shim.js" ) , include_str ! ( "./js/shim.js" ) ) ?;
59+ let shim = if env:: var ( "RUN_TO_COMPLETION" ) . is_ok ( ) {
60+ SHIM_TEMPLATE . replace ( "$WAIT_UNTIL_RESPONSE" , "this.ctx.waitUntil(response);" )
61+ } else {
62+ SHIM_TEMPLATE . replace ( "$WAIT_UNTIL_RESPONSE" , "" )
63+ } ;
64+
65+ write_string_to_file ( worker_path ( "shim.js" ) , shim) ?;
5866
5967 bundle ( & esbuild_path) ?;
6068
You can’t perform that action at this time.
0 commit comments