Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: NextJs 13 incompatibility #1352

Closed
qruz-hq opened this issue Nov 7, 2022 · 24 comments
Closed

[Bug]: NextJs 13 incompatibility #1352

qruz-hq opened this issue Nov 7, 2022 · 24 comments
Assignees
Labels
bug Something isn't working

Comments

@qruz-hq
Copy link

qruz-hq commented Nov 7, 2022

Current Behavior

On the dev environnement everything runs as it should, but on production (build) it throws a client-side error.

Everything worked as it should on NextJs 12. I only updated the NextJS version to the latest.

Expected Behavior

No response

Steps To Reproduce

  1. Add core package to a NextJS 13 app
  2. Build the app
  3. Run the app

What package is effected by this issue?

@web3-onboard/core

Is this a build or a runtime issue?

Build, Runtime

Package Version

latest (2.10.0)

Node Version

16

What browsers are you seeing the problem on?

No response

Relevant log output

TypeError: Cannot read properties of undefined (reading 'context')
    at az (_app-ce8b79dbd96579e9.js:204:6778)
    at new s9 (_app-ce8b79dbd96579e9.js:247:1482)
    at _app-ce8b79dbd96579e9.js:341:173
    at lo (_app-ce8b79dbd96579e9.js:341:201)
    at 67311 (_app-ce8b79dbd96579e9.js:29:5824196)
    at i (webpack-1e9bcc2803bdfe55.js:1:167)
    at 58473 (_app-ce8b79dbd96579e9.js:29:13498)
    at i (webpack-1e9bcc2803bdfe55.js:1:167)
    at _app-ce8b79dbd96579e9.js:29:13404
    at main-3865b822287975ac.js:1:22562

this points to this part of the code on the built package, couldn't find much on the source, maybe it's a dependency issue ?

...
    set_current_component(component);
    const $$ = component.$$ = {
        fragment: null,
        ctx: [],
        // state
        props,
        update: noop,
        not_equal,
        bound: blank_object(),
        // lifecycle
        on_mount: [],
        on_destroy: [],
        on_disconnect: [],
        before_update: [],
        after_update: [],
        context: new Map(options.context || (parent_component && parent_component.$$ ? parent_component.$$.context : [])),
        // everything else
        callbacks: blank_object(),
        dirty,
        skip_bound: false,
        root: options.target || parent_component.$$.root
    };
...


### Anything else?

_No response_

### Sanity Check

- [X] If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example).
@qruz-hq qruz-hq added the bug Something isn't working label Nov 7, 2022
@taylorjdawson
Copy link
Contributor

@qruz-hq Sweet thanks for raising this, we'll make sure that this gets sorted out shortly!

@qruz-hq
Copy link
Author

qruz-hq commented Dec 1, 2022

Any news ?

@aaronbarnardsound
Copy link
Collaborator

@qruz-hq we are going to try and look at this next week.

@taylorjdawson
Copy link
Contributor

@qruz-hq Here's a working nextjs v13 example! Lmk if that helps :) and then please close if it does. We'll check back next week and close if no response.

@GarrettJMU
Copy link

GarrettJMU commented Dec 14, 2022

@qruz-hq & @taylorjdawson In NextJS you can solve by setting changing in NextJS config file:

swcMinify: false,

@Adamj1232
Copy link
Member

Closing as an example is provided. Please feel free to continue the conversation or reopen if issues persist. Thanks all!

@0xflumedev
Copy link

So this was closed, is it going to actually be fixed in the next release of Next.js? We encountered this when going to production today too. Thanks!

@0xflumedev
Copy link

0xflumedev commented Dec 16, 2022

Also, swcMinify: false did allow the app to load, but now the onboarding dialog CSS's are playing up 🙁

Update: False alarm, the styles seem to be caused by something else..

image

@andyrobert3
Copy link

andyrobert3 commented Jan 8, 2023

@qruz-hq & @taylorjdawson In NextJS you can solve by setting changing in NextJS config file:

swcMinify: false,

@GarrettJMU
Thank you for this!

Why does this change with SWC compiler, fix this? And how did you stumble upon the fix here?
Very curious about your thinking process 😄

@GarrettJMU
Copy link

@andyrobert3 I'd run into this error on something similarly related. From my understanding SWC just has some bugs they are working out. More reading here on something semi-related (and where I hit my bug in the past):
vercel/next.js#36221

@JamieLottering
Copy link

This should be re-opened - the workaround by setting swcMinify to false is not really a long term solution as some NextJS 13 features require it to be enabled (and the perf boost by using it is big).

@Adamj1232 Adamj1232 reopened this Jan 18, 2023
@chinchaun
Copy link

I'm having the same problem with
"next": "13.1.2",
"@web3-onboard/core": "2.8.2",
"@web3-onboard/react": "2.3.2",

@taylorjdawson
Copy link
Contributor

@chinchaun what version of nodejs are you running?

@taylorjdawson
Copy link
Contributor

The issue is with nodejs versions less <18. The simplest fix would be to run the latest most up to date version of node js which includes the fetch pollyfills. For those on nodeJs versions <18 we'll issue a fix and update the issue here once completed.

@chinchaun
Copy link

chinchaun commented Jan 23, 2023

@taylorjdawson

@chinchaun what version of nodejs are you running?

node v16.16.0

@Adamj1232
Copy link
Member

We found the issue, seemed to be a problem with one of our dep packages. Can you confirm it is fixed on your end @chinchaun with the latest core/react/vue (which ever you use) package?

@enzoferey
Copy link
Contributor

@Adamj1232 I can still see this issue on:

  • Node 16.x
  • "next": "13.1.6" (latest)
  • "@web3-onboard/injected-wallets": "2.6.2" (latest)
  • "@web3-onboard/react": "2.6.1" (latest)

@Adamj1232
Copy link
Member

Hey @enzoferey - Im unable to reproduce - are you seeing the same error with the next13 example here - https://github.com/blocknative/web3-onboard/tree/develop/examples/with-nextjs-13

@enzoferey
Copy link
Contributor

enzoferey commented Feb 19, 2023

Hey @Adamj1232, sorry for the delay. Looking at the example, I noticed that I was missing to wrap the app with the provider on the _app file -- which is actually not documented on the website isn't it ?

Once I used the provider passing in the value returning from the init call it worked without having to use swcMinify: false 👍🏻

@Adamj1232
Copy link
Member

@enzoferey good call! We will update the docs to make sure that is clear! Thank you for the heads up!!

@lamaro
Copy link

lamaro commented Mar 3, 2023

Found this issue with Coinbase "@web3-onboard/coinbase": "^2.2.0", and node 14.20 on AWS server.
Local node version is 18.12.1 and works fine

@Adamj1232
Copy link
Member

@lamaro there are some built in polyfils on certain versions of node. Node v14 is out of scope for us, with v16 being the lowest supported by some packages

@Adamj1232
Copy link
Member

Closing as docs have been updated to reflect

@lamaro
Copy link

lamaro commented Mar 15, 2023

Yes, after changing to node v18 and yarn instead of npm, everything works great. For some reason upgrading to node v18 wasn't enough. Yarn solved my issue. Tnx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests