File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ export { wasmModule };
10
10
11
11
class Entrypoint extends WorkerEntrypoint {
12
12
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 ;
14
16
}
15
17
16
18
async queue ( batch ) {
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const OUT_DIR: &str = "build";
18
18
const OUT_NAME : & str = "index" ;
19
19
const WORKER_SUBDIR : & str = "worker" ;
20
20
21
+ const SHIM_TEMPLATE : & str = include_str ! ( "./js/shim.js" ) ;
22
+
21
23
const WASM_IMPORT : & str = r#"let wasm;
22
24
export function __wbg_set_wasm(val) {
23
25
wasm = val;
@@ -54,7 +56,13 @@ pub fn main() -> Result<()> {
54
56
use_glue_import ( ) ?;
55
57
56
58
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) ?;
58
66
59
67
bundle ( & esbuild_path) ?;
60
68
You can’t perform that action at this time.
0 commit comments