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

Deno crash when opening existing node/pnpm project in vscode #23782

Closed
mlandalv opened this issue May 12, 2024 · 2 comments
Closed

Deno crash when opening existing node/pnpm project in vscode #23782

mlandalv opened this issue May 12, 2024 · 2 comments
Labels
lsp related to the language server

Comments

@mlandalv
Copy link

mlandalv commented May 12, 2024

I'm trying to migrate from node to deno by using byonm. The project is not open source so unfortunately I cannot share a reproducable example. Subjective, but it's not a particularly large project either in my opinion (~500 src files including tests).

Currently the project uses:
node 21.7.3
pnpm 9.10

My test:

  1. Open the project in vscode
  2. Enable Deno
  3. Add a deno.json file
{
    "compilerOptions": {
        "jsx": "react-jsx",
        "lib": [
            "deno.window",
            "DOM"
        ]
    },
    "unstable": ["byonm"]
}

Output

Starting Deno language server...
  version: 1.43.3 (release, x86_64-unknown-linux-gnu)
  executable: /home/martin/.deno/bin/deno
Connected to "Code - OSS" 1.90.0
Enabling import suggestions for: https://deno.land
Hit the language server document preload limit of 1000 file system entries. You may want to use the "deno.enablePaths" configuration setting to only have Deno partially enable a workspace or increase the limit via "deno.documentPreloadLimit". In cases where Deno ends up using too much memory, you may want to lower the limit.
Refreshing configuration tree...
  Resolved Deno configuration file: "file:///[redacted]/deno.json"
  Resolved lockfile: "file:///[redacted]/deno.lock"
  Resolved package.json: "/[redacted]/package.json"
Could not set npm package requirements. Error getting response at https://registry.npmjs.org/@[redacted_scope]/[redacted_pkg1] for package "@[redacted_scope]/[redacted_pkg1]": An npm specifier not found in cache: "@[redacted_scope]/[redacted_pkg1]", --cached-only is specified.
Server ready.
Could not set npm package requirements. Error getting response at https://registry.npmjs.org/@[redacted_scope]/[redacted_pkg1] for package "@[redacted_scope]/[redacted_pkg1]": An npm specifier not found in cache: "@[redacted_scope]/[redacted_pkg1]", --cached-only is specified.

And then after a couple of seconds it crashes.

<--- Last few GCs --->

[48093:0x723b04142000]    40902 ms: Mark-Compact (reduce) 3068.0 (3119.2) -> 3067.5 (3118.0) MB, pooled: 0 MB, 336.96 / 0.01 ms  (+ 1.9 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 722 ms) (average mu = 0.892,[48093:0x723b04142000]    40905 ms: Scavenge 3068.5 (3118.0) -> 3068.2 (3121.0) MB, pooled: 0 MB, 1.43 / 0.00 ms  (average mu = 0.892, current mu = 0.631) allocation failure; 


<--- JS stacktrace --->



#
# Fatal JavaScript out of memory: Reached heap limit
#
==== C stack trace ===============================

    /home/martin/.deno/bin/deno(+0x2be0513) [0x5c7cec355513]
    /home/martin/.deno/bin/deno(+0x2bdf7fb) [0x5c7cec3547fb]
    /home/martin/.deno/bin/deno(+0x2bdb138) [0x5c7cec350138]
    /home/martin/.deno/bin/deno(+0x2c2d221) [0x5c7cec3a2221]
    /home/martin/.deno/bin/deno(+0x2dcd7d7) [0x5c7cec5427d7]
    /home/martin/.deno/bin/deno(+0x2dcbd19) [0x5c7cec540d19]
    /home/martin/.deno/bin/deno(+0x2dc05b0) [0x5c7cec5355b0]
    /home/martin/.deno/bin/deno(+0x2dc0dc5) [0x5c7cec535dc5]
    /home/martin/.deno/bin/deno(+0x2da6711) [0x5c7cec51b711]
    /home/martin/.deno/bin/deno(+0x32204a2) [0x5c7cec9954a2]
    [0x5c7c8d66b036]
[Info  - 7:52:23 PM] Connection to server got closed. Server will restart.

Not much to go on...any tips on how to debug this are appreciated.

Btw, If I add a task:

    "tasks": {
        "start": "deno run -A --unstable-byonm scripts/start.js"
    }

and run deno task start it actually works. So perhaps the bug is related to the vscode plugin or the lsp?

EDIT 1: Updated the deno.json config.

@mlandalv mlandalv changed the title Deno when opening existing node/pnpm project in vscode Deno crash when opening existing node/pnpm project in vscode May 12, 2024
@bartlomieju
Copy link
Member

You probably have a lot of dependencies in your project, which is suggested by the OOM error where V8 can't allocate more memory than 3Gb (which is the default heap limit). You should be able to work around the problem by setting deno. maxTsServerMemory in your .vscode/settings.json to a bigger value - eg. 6144 to increase the limit to 6Gb.

@bartlomieju bartlomieju added the lsp related to the language server label May 12, 2024
@mlandalv
Copy link
Author

Increasing deno.maxTsServerMemory fixed it. Thank you @bartlomieju.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lsp related to the language server
Projects
None yet
Development

No branches or pull requests

2 participants