metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
357 stars 182 forks source link

AbortController is undefined when using Metaplex JS 0.11.7 SDK in a NextJS app #162

Closed zfaizal2 closed 2 years ago

zfaizal2 commented 2 years ago

We’re developing a library that uses the metaplex JS SDK as a dependency. When using this library in a nextJS app, the app errors out with the error below.

When using this with a create-react-app based app however, things work just fine.

Uncaught TypeError: Cannot destructure property 'AbortController' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined.
nodeStackFrames.js:40
    getNodeError nodeStackFrames.js:40
    _callee$/< index.js:322
    (Async: setTimeout handler)
    _callee$ index.js:305
    Babel 10
        tryCatch
        invoke
        method
        asyncGeneratorStep
        _next
        (Async: promise callback)
    asyncGeneratorStep
        _next
        _asyncToGenerator
        _asyncToGenerator
        _initNext
    initNext index.js:375
    <anonymous> next-dev.js:46
    NextJS 6
        js
        factory
        __webpack_require__
        __webpack_exec__
        <anonymous>
        webpackJsonpCallback
    webpackJsonpCallback self-hosted:1162
    <anonymous> NextJS

Has anyone seen this before? What are potential steps or avenues to resolve this?

Versions used

@metaplex-foundation/js : 0.11.7

next-js: 12.0.7

mayognaise commented 2 years ago

@zfaizal2 Have you tried adding the code below?

next.config.js

/** @type {import('next').NextConfig} */

module.exports = {
  webpack: (config) => {
    config.resolve.fallback = { fs: false, path: false };
    return config;
  },
};
zfaizal2 commented 2 years ago

@mayognaise Thanks for the suggestion, I tried that but still facing the same errors.

mayognaise commented 2 years ago

@zfaizal2 Could you share your code? I use exact same environment so I might be able to help you (Although my nextjs verison is 12.1.6)

Fyi there was an issue related with AbortController

lorisleiva commented 2 years ago

Hi there 👋

Would you mind upgrading to version 0.12.0 and let me know if that fixes your issue?

lorisleiva commented 2 years ago

Hi there 👋

I'm going to close this due to inactivity but feel free to open a new issue using the latest version with updated information if you need to.

Thank you for your understanding.