v8::Module::Evaluate returns unexpected completion value

33 views
Skip to first unread message

Steve M

unread,
Apr 27, 2021, 12:55:04 PM4/27/21
to v8-users
Hi,

I'm transitioning from v8 version 8.2.0.0. After syncing to the latest master branch, Mon Apr 26, I'm seeing the return value from Module::Evaluate return an "object" type, when I expected to see a "string" type. The module status is 'kEvaluated'.

The actual script is just returning a completion value of type string.

//-------------------
"Complete";

Previously, Evaluate was returning the expected string value.

Evaluating the script using the ScriptCompiler::Run flow works as expected.

What am I missing? 
Steve






Shu-yu Guo

unread,
Apr 27, 2021, 1:10:51 PM4/27/21
to v8-u...@googlegroups.com
Hi Steve,

Tip of tree for V8 recently turned on the top-level await feature on by default. Previously it was gated behind the --harmony-top-level-await flag.

With top-level await, Module::Evaluate always returns a Promise object. This Promise is resolved when the module successfully evaluates, and is rejected otherwise. You can use the Promise API to attach then handlers.

If the module graph you're evaluating is not asynchronous and doesn't have any modules with top-level await in, the Promise returned by Module::Evaluate is already settled, and you should be able to pull the result value out without attaching a handler.

Hope this helps,
shu

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/2c42e59a-5700-45d5-a0f4-c1894c3c4a05n%40googlegroups.com.

Steve M

unread,
Apr 27, 2021, 1:46:03 PM4/27/21
to v8-users
thanks shu. 

And thanks for the quick reply.

Steve.
Reply all
Reply to author
Forward
0 new messages