-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from supabase/load-mod-in-boot
fix: move main module load to worker boot phase
- Loading branch information
Showing
4 changed files
with
76 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * from "https://deno.land/[email protected]/http/server.ts" | ||
|
||
interface reqPayload { | ||
name: string; | ||
} | ||
|
||
console.log('server started modified'); | ||
|
||
serve(async (req: Request) => { | ||
const { name } : reqPayload = await req.json(); | ||
const data = { | ||
message: `Hello ${name} from foo!`, | ||
test: 'foo' | ||
} | ||
|
||
return new Response( | ||
JSON.stringify(data), | ||
{ headers: { "Content-Type": "application/json", "Connection": "keep-alive" } }, | ||
) | ||
}, { port: 9005 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::collections::HashMap; | ||
|
||
use base::worker_ctx::create_worker; | ||
use sb_worker_context::essentials::{EdgeContextInitOpts, EdgeContextOpts, EdgeUserRuntimeOpts}; | ||
|
||
#[tokio::test] | ||
async fn test_worker_boot_invalid_imports() { | ||
let user_rt_opts = EdgeUserRuntimeOpts::default(); | ||
let opts = EdgeContextInitOpts { | ||
service_path: "./test_cases/invalid_imports".into(), | ||
no_module_cache: false, | ||
import_map_path: None, | ||
env_vars: HashMap::new(), | ||
conf: EdgeContextOpts::UserWorker(user_rt_opts), | ||
}; | ||
let result = create_worker(opts).await; | ||
|
||
assert!(result.is_err()); | ||
assert_eq!(result.unwrap_err().to_string(), "worker boot error"); | ||
} |