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

Global variable in custom server since 13.4.13 #54435

Closed
1 task done
sgarnotel opened this issue Aug 23, 2023 · 2 comments
Closed
1 task done

Global variable in custom server since 13.4.13 #54435

sgarnotel opened this issue Aug 23, 2023 · 2 comments
Labels
bug Issue was opened via the bug report template. locked

Comments

@sgarnotel
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jul 13 16:27:29 UTC 2
    Binaries:
      Node: 16.20.0
      npm: 8.19.4
      Yarn: 1.22.19
      pnpm: 8.5.0
    Relevant Packages:
      next: 13.4.20-canary.2
      eslint-config-next: 13.4.19
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/Airthium/next-global

To Reproduce

Using the reproduction, run yarn and yarn dev and open http://localhost:3000/ will pop the following error

Error [ReferenceError]: myvar is not defined

If you change next version to 13.4.12, it works

Describe the Bug

In a larger code, I use a global variable (here global.myvar) defined when the custom server starts, in order to start my database, and store a function. I use this function in the server-side to perform queries and stop the database when I stop the server.
It worked like a charm until next 13.4.12.

Since next 13.4.13, the global variable is not available in the server side.

Expected Behavior

Same behavior of next 13.4.12

Which browser are you using? (if relevant)

Chrome 115.0.5790.170

How are you deploying your application? (if relevant)

custom server

@sgarnotel sgarnotel added the bug Issue was opened via the bug report template. label Aug 23, 2023
@balazsorban44
Copy link
Member

balazsorban44 commented Aug 23, 2023

Closing in favor of #54440. Feel free to comment there! (The title might sound differently, but it's essentially the same cause)

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Sep 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

No branches or pull requests

2 participants