-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
Error: global is not defined - when creating a matrix client #4450
Comments
I think matrix-js-sdk currently expects the environment to provide a polyfill for I am very surprised that you found this started with 34.4.0, because as far as I know this code has not changed in years. As for solutions: pull-requests to replace In the meantime, maybe you can work around it. I'm not familiar with next.js but maybe you can configure it to provide a polyfill? Alternatively, if you provide a concrete implementation of let store = new MemoryStore({ localStorage });
let client = createClient({ store }); |
I've noticed that this started breaking somewhere in the vicinity of v33.0.0-v34.0.0. Building and running our application on v32.4.0 didn't result in an error, but v33.x.x resulted in #4284, and v34.0.0 results in the error as described above. Something did change. |
That's very confusing. If you look at, say, |
It is indeed quite odd. My guess is that something was changed in the way the library was exported? There were some changes to export as an ESM module, I wonder if that impacts the way Either way, I'll progress trying to move away from global so the next release should be fine. |
Matrix SDK is not compatible with the latest version of Next.js (14.2.15). Creating a client causes an error in the
amendClientOpts
function, where it uses theglobal
variable, which is not defined in this environment. The error started occurring with matrix-js-sdk version 34.4.0. The error appears on this line, but the global variable is used multiple times.The code is simple. Here’s an example.
Here, I have a screenshot of the error.
The browser recognizes
globalThis
but notglobal
.global
is available only in a node.js environment. How can I run Matrix on Next.js? Thanks in advance for the help.The text was updated successfully, but these errors were encountered: