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

SSR SourceMap not loaded when debugging #3288

Closed
6 tasks done
DylanPiercey opened this issue May 6, 2021 · 8 comments · Fixed by #11576 or #11780
Closed
6 tasks done

SSR SourceMap not loaded when debugging #3288

DylanPiercey opened this issue May 6, 2021 · 8 comments · Fixed by #11576 or #11780
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@DylanPiercey
Copy link
Contributor

DylanPiercey commented May 6, 2021

Describe the bug

Currently it looks like when debugging the node process with source maps enabled (node --inspect --enable-source-maps ./source.js) that the source maps are not actually loaded.

Reproduction

Load any file via ssrLoadModule with a debugger.
You will see that the debugger shows compiled code instead of the source.

eg:

source.js

const { createServer } = require('vite')

(async () => {
  const server = await createServer({ server: { middlewareMode: true } });
  await server.ssrLoadModule("./debug.js");
})();

debug.js

debugger;
console.log("debugging", import.meta.url);

Then run

node --inspect-brk --enable-source-maps ./source.js

And finally connect your favorite debugger.

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 504.64 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v14.16.1/bin/npm
  Browsers:
    Edge: 90.0.818.51
    Firefox: 87.0
    Safari: 14.1
  npmPackages:
    vite: ^2.2.4 => 2.2.4

Used package manager: npm


Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
@DylanPiercey
Copy link
Contributor Author

As a side note, I believe if source-maps were supported in SSR mode we could get rid of the (slightly awkward) ssrFixStackTrace api.

@Shinigami92 Shinigami92 added bug p3-minor-bug An edge case that only affects very specific usage (priority) labels May 8, 2021
@maomincoding
Copy link

@DylanPiercey yes.

@jere2101
Copy link

jere2101 commented Jan 3, 2023

Hi,
Is there currently any plan or roadmap to fix this issue ?
I am currently working on a project with SvelteKit and one of the only things I'm missing painfully is the option to debug server side code.
Currently the only option is to put console.logs everywhere but on the server side especially in complex scenarios that's a big pain point.
In my opinion this is critical for a better developer experience, especially people that come from other languages will turn their back on something like svelteKit when they find out that they can't debug properly, instead have to use the console output.

Thanks in advance for help ;D

@gsxdsm
Copy link

gsxdsm commented Feb 25, 2023

This is a huge development workflow blocker - would be great to get fixes merged in!

@cyco130
Copy link
Contributor

cyco130 commented Feb 27, 2023

@gsxdsm Now there's a solution: cyco130/vavite#17

It may one day make it into Vite itself, maybe.

@gsxdsm
Copy link

gsxdsm commented Feb 27, 2023

Thanks cyco! Checked out vavite - very cool! I've been trying to get it working with Sveltekit (or at least the node-loader package into vite) but not having any luck. Will keep tinkering with it.

@cyco130
Copy link
Contributor

cyco130 commented Feb 27, 2023

but not having any luck

Here's an example repo. Feel free to open an issue at vavite's repo or hit me on Rakkas's Discord channel.

@gsxdsm
Copy link

gsxdsm commented Feb 27, 2023

That worked! Thank you so much!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.