Content-Length: 301202 | pFad | http://github.com/micropython/micropython/commit/92b3b69648304b292fb59e734fc9a61a188ba419

D2 webassembly/proxy_c: Fix proxy then reject handling. · micropython/micropython@92b3b69 · GitHub
Skip to content

Commit 92b3b69

Browse files
committed
webassembly/proxy_c: Fix proxy then reject handling.
An exception on the Python side should be passed to the Promise reject callback on the JavaScript side. Signed-off-by: Damien George <damien@micropython.org>
1 parent 4c3f5f5 commit 92b3b69

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: ports/webassembly/proxy_c.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,11 @@ EM_JS(void, js_then_resolve, (uint32_t * ret_value, uint32_t * resolve, uint32_t
296296
resolve_js(ret_value_js);
297297
});
298298

299-
EM_JS(void, js_then_reject, (uint32_t * resolve, uint32_t * reject), {
299+
EM_JS(void, js_then_reject, (uint32_t * ret_value, uint32_t * resolve, uint32_t * reject), {
300+
const ret_value_js = proxy_convert_mp_to_js_obj_jsside(ret_value);
300301
const resolve_js = proxy_convert_mp_to_js_obj_jsside(resolve);
301302
const reject_js = proxy_convert_mp_to_js_obj_jsside(reject);
302-
reject_js(null);
303+
reject_js(ret_value_js);
303304
});
304305

305306
// *FORMAT-OFF*
@@ -335,10 +336,12 @@ static mp_obj_t proxy_resume_execute(mp_obj_t self_in, mp_obj_t value, mp_obj_t
335336
uint32_t out[PVN];
336337
js_then_continue(ref, out_py_resume, out_resolve, out_reject, out);
337338
return proxy_convert_js_to_mp_obj_cside(out);
338-
} else {
339-
// MP_VM_RETURN_EXCEPTION;
340-
js_then_reject(out_resolve, out_reject);
341-
nlr_raise(ret_value);
339+
} else { // ret_kind == MP_VM_RETURN_EXCEPTION;
340+
// Pass the exception through as an object to reject the promise (don't raise/throw it).
341+
uint32_t out_ret_value[PVN];
342+
proxy_convert_mp_to_js_obj_cside(ret_value, out_ret_value);
343+
js_then_reject(out_ret_value, out_resolve, out_reject);
344+
return mp_const_none;
342345
}
343346
}
344347

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micropython/micropython/commit/92b3b69648304b292fb59e734fc9a61a188ba419

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy