Thanks for the advice, that got me back on track. The failure mentioned in 
my original post only occurs when there's nothing at all exported from the 
module. I speculate the namespace object gets garbage collected in that 
situation. When I tested with actual valid modules, everything works fine.
Thanks again,
Ben

On Tuesday, 17 November 2020 at 21:21:25 UTC+10:30 Ben Ernst wrote:

> Thank you for the advice Camillo, the test you referred me to is very 
> helpful. I will prepare a good code sample and come back to this 
> conversation.
>
> Regards,
> Ben
>
>
> On Tue, 17 Nov 2020 at 19:54, Camillo Bruni <cbr...@chromium.org> wrote:
>
>> Hi,
>>
>> The ModuleNamespace 
>> <https://source.chromium.org/chromium/chromium/src/+/master:v8/include/v8.h;drc=5d658083d506ff1bf14abdd2221d94cbcf4fae96;bpv=1;bpt=1;l=1591?q=v8::Module>
>>  
>> object is the proper choice, you can have a look at the existing tests 
>> <https://source.chromium.org/chromium/chromium/src/+/master:v8/test/cctest/test-api.cc;l=26235;drc=5d658083d506ff1bf14abdd2221d94cbcf4fae96;bpv=1;bpt=1?q=v8::Module>
>> .
>> For future reference, you will usually find (a bit hidden and obscure, I 
>> agree) existing tests in V8's test-api.cc 
>> <https://source.chromium.org/chromium/chromium/src/+/master:v8/test/cctest/test-api.cc>
>> .
>>
>> Could you provide some more example code for the error you get 
>> with persistent handles?
>>
>> cheers,
>> Camillo
>>
>> On Tue, 17 Nov 2020 at 01:11, Ben Ernst <boi...@gmail.com> wrote:
>>
>>> I am migrating my V8 code from using "plain scripts" to using "ES6 
>>> Modules". There are a few concepts that I am struggling with. 
>>>
>>> First, how might I retrieve a class definition defined in a module? 
>>> Previously I would have used the "global" object on the "context" (i.e. 
>>> context->Global()), and found the class definition there. I can't find a 
>>> good example on how to do that in a module. I am experimenting with 
>>> Module::GetModuleNamespace(), but I'm not sure that I'm on the right track.
>>>
>>> Second, am I allowed to take a persistent handle to a module? I am 
>>> finding that after restoring a module from a persistent handle, I encounter 
>>> the failure below.
>>>
>>> #
>>> # Fatal error in C:\621300de\v8\src/api/api-inl.h, line 128
>>> # Debug check failed: allow_empty_handle || that != nullptr.
>>> #
>>> #
>>> #
>>> #FailureMessage Object: 0000006114FBC2E0
>>> ==== C stack trace ===============================
>>>
>>>         v8::base::debug::StackTrace::StackTrace 
>>> [0x0,000,7FF,60D,F82,80B+27]
>>>         v8::platform::DefaultPlatform::PostJob 
>>> [0x0,000,7FF,60D,F7F,1E1+401]
>>>         V8_Fatal [0x0,000,7FF,60C,251,B87+167]
>>>         v8::base::PrintCheckOperand<unsigned __int64> 
>>> [0x0,000,7FF,60C,251,683+627]
>>>         v8::Module::GetStatus [0x0,000,7FF,60C,1E0,3FD+141]
>>>         v8::Module::GetModuleNamespace [0x0,000,7FF,60C,1D1,243+19]
>>>
>>> -- 
>>> -- 
>>> 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/6e1f91bb-9d1b-4e3e-b772-c1cdf71afb06n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/v8-users/6e1f91bb-9d1b-4e3e-b772-c1cdf71afb06n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> Camillo Bruni |  Software Engineer, V8 |  Google Germany GmbH |  Erika-Mann 
>> Str. 33, 80636 München 
>>
>> Registergericht und -nummer: Hamburg, HRB 86891 | Sitz der Gesellschaft: 
>> Hamburg | Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
>>
>> Diese E-Mail ist vertraulich. Falls Ssie diese fälschlicherweise erhalten 
>> haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, 
>> löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, 
>> dass die E-Mail an die falsche Person gesendet wurde.  This e-mail is 
>> confidential. If you received this communication by mistake, please don't 
>> forward it to anyone else, please erase all copies and attachments, and 
>> please let me know that it has gone to the wrong person.
>>
>> -- 
>> -- 
>> 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/CAOeS1i9mEbcpxGQr1uNk%3DfAMPDi%2Bz%2Bzkun0eiopfphqErJJLAQ%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/v8-users/CAOeS1i9mEbcpxGQr1uNk%3DfAMPDi%2Bz%2Bzkun0eiopfphqErJJLAQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
-- 
v8-users mailing list
v8-users@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/bb572a7e-606f-4762-a91b-f989a48a5717n%40googlegroups.com.

Reply via email to