You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: I could totally be doing something stupid here, but I can't see what.
Code that reproduces the issue for me:
// mod.tsimport{SlackAPI}from"https://deno.land/x/[email protected]/mod.ts";constgetClientAsync=async()=>{// This return style always failsreturnSlackAPI("foo");};constgetClientNestedAsync=async()=>{// Nesting it in an object succeedsreturn{c: SlackAPI("foo")};};constgetClient=()=>{// Returning from a non-async function succeedsreturnSlackAPI("foo");};construn=async()=>{console.log("Running");SlackAPI("foo");console.log("Got inline client");getClient();console.log("Got client from func");awaitgetClientNestedAsync();console.log("Got client from nested async func");awaitgetClientAsync();console.log("Got client from async func");};if(import.meta.main){awaitrun();}
Run this with: deno run --allow-all mod.ts
Deno version: deno 1.44.4+86010be
If I run the above code, I get this output:
Running
Got inline client
Got client from func
Got client from nested async func
error: Top-level await promise never resolved
await run();
^
at <anonymous> (file:///Users/tm/Code/scratch/denobug/mod.ts:31:3)
I can swap the order of the getClient calls around - it always fails at the call to the async, non-nested return.
I first saw this behaviour in a worker, where it doesn't even show the error. It just seems to... stop. No error, nothing to show it has crashed - I have a lot going on in my worker though so can't rule out suppression.
I've also tested the returned client in all cases, and in all cases the client is functional/can make calls as expected. I've tried every odd variation I can think of, including assigning the client to a variable, using it first, then returning.
It seems that no matter what, if that specific value is returned from an async function, it crashes Deno and can not be caught.
The text was updated successfully, but these errors were encountered:
@marvinhagemeister Having dug into the Slack code more and taught myself a bit more about Proxies and nested promises, I'm not sure this is an issue with Deno.
The Slack code returns a Proxy with a getter. Deno checks if this is thenable, which is caught by the getter which in turn will eventually return a proxied function (so it appears as if it's a promise).
I suppose Deno could potentially help with making it clear what just happened, but I wonder if this is expected behaviour other than that.
Disclaimer: I could totally be doing something stupid here, but I can't see what.
Code that reproduces the issue for me:
Run this with:
deno run --allow-all mod.ts
Deno version:
deno 1.44.4+86010be
If I run the above code, I get this output:
I can swap the order of the getClient calls around - it always fails at the call to the async, non-nested return.
I first saw this behaviour in a worker, where it doesn't even show the error. It just seems to... stop. No error, nothing to show it has crashed - I have a lot going on in my worker though so can't rule out suppression.
I've also tested the returned client in all cases, and in all cases the client is functional/can make calls as expected. I've tried every odd variation I can think of, including assigning the client to a variable, using it first, then returning.
It seems that no matter what, if that specific value is returned from an async function, it crashes Deno and can not be caught.
The text was updated successfully, but these errors were encountered: