Skip to content

Commit 09ddc27

Browse files
committed
minor cleanup
1 parent efc08e4 commit 09ddc27

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

crates/funcgg-runtime/src/ext/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async fn op_set_response(
8787
let state_borrow = state.borrow();
8888
let sandbox_state = state_borrow.borrow::<Rc<RefCell<super::sandbox::State>>>();
8989
let mut borrowed = sandbox_state.borrow_mut();
90-
(borrowed.response_oneshot_tx.take(), borrowed.request_id)
90+
(borrowed.response_tx.take(), borrowed.request_id)
9191
};
9292

9393
res.apply_runtime_headers(request_id);

crates/funcgg-runtime/src/js/worker.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ async function resolveHandler() {
2020
}
2121

2222
async function work() {
23+
let response;
2324
try {
2425
const handler = await resolveHandler();
25-
const response = await handler(Func.request);
26-
return Func.setResponse(response);
26+
response = await handler(Func.request);
2727
} catch (error) {
28-
const msg = error && error.message ? error.message : String(error);
29-
return new Response(`Internal Server Error: ${msg}`, {
28+
const msg =
29+
error.stack || `Internal Server Error: ${error?.message || error}`;
30+
response = new Response(msg, {
3031
status: 500,
3132
});
33+
} finally {
34+
Func.setResponse(response);
3235
}
3336
}
3437

crates/funcgg-runtime/src/sandbox.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct State {
2828
pub request_id: Uuid,
2929
pub incoming_body_rx: Rc<Mutex<mpsc::Receiver<Result<bytes::Bytes, String>>>>,
3030
pub outgoing_body_tx: mpsc::Sender<bytes::Bytes>,
31-
pub response_oneshot_tx: Option<oneshot::Sender<http::Response>>,
31+
pub response_tx: Option<oneshot::Sender<http::Response>>,
3232
}
3333

3434
pub struct Sandbox {
@@ -42,7 +42,7 @@ impl Sandbox {
4242
startup_snapshot: Option<&'static [u8]>,
4343
incoming_body_rx: mpsc::Receiver<Result<bytes::Bytes, String>>,
4444
outgoing_body_tx: mpsc::Sender<bytes::Bytes>,
45-
response_oneshot_tx: oneshot::Sender<http::Response>,
45+
response_tx: oneshot::Sender<http::Response>,
4646
) -> Result<Self> {
4747
_ = CryptoProvider::install_default(aws_lc_rs::default_provider());
4848

@@ -52,7 +52,7 @@ impl Sandbox {
5252
res: None,
5353
incoming_body_rx: Rc::new(Mutex::new(incoming_body_rx)),
5454
outgoing_body_tx,
55-
response_oneshot_tx: Some(response_oneshot_tx),
55+
response_tx: Some(response_tx),
5656
}));
5757

5858
let extension_transpiler = Rc::new(loader::transpile);

crates/funcgg-worker/src/pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Pool {
8282
http_request: http::Request,
8383
incoming_body_rx: mpsc::Receiver<Result<bytes::Bytes, String>>,
8484
outgoing_body_tx: mpsc::Sender<bytes::Bytes>,
85-
response_oneshot_tx: oneshot::Sender<http::Response>,
85+
response_tx: oneshot::Sender<http::Response>,
8686
) -> Result<(), String> {
8787
let request_id = Uuid::now_v7();
8888

@@ -93,7 +93,7 @@ impl Pool {
9393
http_request,
9494
incoming_body_rx,
9595
outgoing_body_tx,
96-
response_oneshot_tx,
96+
response_tx,
9797
};
9898

9999
tracing::debug!(

crates/funcgg-worker/src/worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct WorkerRequest {
1414
pub http_request: http::Request,
1515
pub incoming_body_rx: mpsc::Receiver<Result<bytes::Bytes, String>>,
1616
pub outgoing_body_tx: mpsc::Sender<bytes::Bytes>,
17-
pub response_oneshot_tx: oneshot::Sender<http::Response>,
17+
pub response_tx: oneshot::Sender<http::Response>,
1818
}
1919

2020
pub struct Worker {
@@ -63,7 +63,7 @@ impl Worker {
6363
Some(STARTUP_SNAPSHOT),
6464
request.incoming_body_rx,
6565
request.outgoing_body_tx,
66-
request.response_oneshot_tx,
66+
request.response_tx,
6767
) {
6868
Ok(rt) => rt,
6969
Err(e) => {

0 commit comments

Comments
 (0)