ngxtension / ngxtension-platform

Utilities for Angular
https://ngxtension.netlify.app/
MIT License
531 stars 77 forks source link

Pre-rendering (SSG) causes a v8::FromJust Maybe value is Nothing #418

Closed cskiwi closed 1 week ago

cskiwi commented 4 weeks ago

If I use any of the functions of ngxtension I get the following output when doing SSG:

FATAL ERROR: v8::FromJust Maybe value is Nothing
 1: 00007FF700AD6CEB node::SetCppgcReference+18123
 2: 00007FF700A48BB9 node::OnFatalError+265
 3: 00007FF7014A9DB3 v8::api_internal::FromJustIsNothing+83
 4: 00007FF700933C1C RSA_meth_get_flags+156924
 5: 00007FF700ACBCA9 node_api_throw_syntax_error+170265
 6: 00007FF700AAAF9B node_api_throw_syntax_error+35851
 7: 00007FF700B3C74B uv_update_time+491
 8: 00007FF700B3C2C4 uv_run+900
 9: 00007FF700B0D1C5 node::SpinEventLoop+405
10: 00007FF700937DFB RSA_meth_get_flags+173787
11: 00007FF700932A98 RSA_meth_get_flags+152440
12: 00007FF700B2A99D uv_poll_stop+237
13: 00007FF701CEFF10 inflateValidate+152096
14: 00007FFE0F6A257D BaseThreadInitThunk+29
15: 00007FFE1062AA48 RtlUserThreadStart+40

I'm trying to figure out what might be causing this. However I could only pinpoint that it was using anything of ngextension. I don't have time right now to make an example.

Will try to make it tomorrow, but i'm making this issue to already keep track of it

eneajaho commented 4 weeks ago

We will need more information on this one.

cskiwi commented 1 week ago

Hi, @eneajaho,

I've found that it was an edge case using:

Removing the gql of the query and using it as unkown/any/TypedDocumentNode, would fix this error, still strange how this this would matter.

I don't know if this error is ngexension related or apollo related

I've created a template here: https://github.com/cskiwi/angular-nestjs-full-starter if you would go to file: libs\frontend\pages\home\src\components\home\page-home.component.ts

There change

exampleFetch = derivedAsync(() =>
    this.apollo.query({
      query: `
        query Profile {
          me {
            id
            name
          }
        }
      ` as unknown as TypedDocumentNode,
    }),
  );

to

 exampleFetch = derivedAsync(() =>
    this.apollo.query({
      query: gql` // <-- use the gql import here
        query Profile {
          me {
            id
            name
          }
        }
      ` ,
    }),
  );

the error will show up

cskiwi commented 1 week ago

After some further investigation I was able to narrowed the issue down to my Apollo not being configured correctly for SSR/SSG.

Sorry to bother you with this issue. It wasn't easy to spot that it came from there :(