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

vite-node sourcemap changes not reflected after HMR #6642

Open
6 tasks done
theoephraim opened this issue Oct 5, 2024 · 3 comments · May be fixed by #6774
Open
6 tasks done

vite-node sourcemap changes not reflected after HMR #6642

theoephraim opened this issue Oct 5, 2024 · 3 comments · May be fixed by #6774
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) vite-node

Comments

@theoephraim
Copy link

Describe the bug

I am using vite-node directly and while sourcemaps appear to be generated correctly, and error line numbers are correct for an initial execution, after HMR and clearing the module from the cache, line numbers are no longer correct. While the file is being updated and the new code is executing, it seems like the original sourcemap is somehow sticking around?

Is there another method that must be called to make sure the new sourcemap is respected?

Reproduction

https://stackblitz.com/~/github.com/dmno-dev/vite-node-sourcemap-issue

System Info

System:
    OS: macOS 13.6.7
    CPU: (12) arm64 Apple M2 Max
    Memory: 3.00 GB / 96.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/Library/Caches/fnm_multishells/32938_1728091914366/bin/node
    Yarn: 1.22.22 - ~/Library/Caches/fnm_multishells/32938_1728091914366/bin/yarn
    npm: 10.2.4 - ~/Library/Caches/fnm_multishells/32938_1728091914366/bin/npm
    pnpm: 9.6.0 - ~/Library/Caches/fnm_multishells/32938_1728091914366/bin/pnpm
    bun: 1.1.21 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 129.0.6668.90
    Safari: 16.6
  npmPackages:
    vite: ^5.4.8 => 5.4.8

Used Package Manager

pnpm

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 5, 2024

Can you reproduce the same with vite-node cli watch mode?

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 5, 2024

I wasn't sure about your custom handleHotUpdate, but I can reproduce with vite-node --watch https://github.com/hi-ogawa/reproductions/tree/main/vitest-6642-vite-node-watch-error-stack and I assume it's the same issue.

@hi-ogawa hi-ogawa added vite-node p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Oct 5, 2024
@theoephraim
Copy link
Author

Nice! At least it's consistent. I also noticed that adding a log on the getSourceMap function, it only gets called once.

this seems to be the related PR

Perhaps @sheremet-va has an idea of what's going on?

@hi-ogawa hi-ogawa linked a pull request Oct 23, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) vite-node
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants