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

Source maps are broken when using houdini plugin #1154

Open
pdaddyo opened this issue Sep 12, 2023 · 10 comments
Open

Source maps are broken when using houdini plugin #1154

pdaddyo opened this issue Sep 12, 2023 · 10 comments
Labels
Bug Something isn't working like it should Core Issues related to the core infrastructure

Comments

@pdaddyo
Copy link

pdaddyo commented Sep 12, 2023

Describe the bug

Apparently due to the source transformation that happens in the houdini plugin.

Source maps being broken is affecting our ability to trap errors with Sentry etc - v difficult to debug our large app at all now.

This issue was discussed on discord here but adding to github to see if community can help address.

Thanks!

Severity

serious, but I can work around it

Steps to Reproduce the Bug

To reproduce in the HoudiniGraphQL/example-sveltekit-todo repo, I've added a single debugger statement to the top of handleClick() in lib/ItemEntry.svelte, when triggered the Chrome debugger has the line significantly wrong. Manual breakpoints set in Chrome / vscode also don't line up due to the incorrect source map.
image

Reproduction

No response

@AlecAivazis
Copy link
Collaborator

Ah damn, sorry to hear that! Getting the sourcemaps wired up correctly has been a long running thorn in my side. Do you have any time/energy to hunt this down? If so I'd gladly offer any guidance you need

@pdaddyo
Copy link
Author

pdaddyo commented Sep 19, 2023

Unfortunately I'm v time poor at the moment but happy to at least see how hard it would be and help if I can. As you say Recast should be handling it but (from previous discussion) looks like there's string interpolation e.g. here. I also noted that this affects .ts files as well as .svelte files so it's likely not the only issue... thorny indeed :)

@AlecAivazis AlecAivazis added Bug Something isn't working like it should Core Issues related to the core infrastructure labels Sep 23, 2023
@shadow-identity
Copy link

Is it a reason that trace backs are also broken? When it points to unrelated pieces of code, not to actual issue source.

@tomcharwood
Copy link

This is causing so many issues for us too - would be great to solve!

@knd775
Copy link
Contributor

knd775 commented Oct 12, 2023

Ah damn, sorry to hear that! Getting the sourcemaps wired up correctly has been a long running thorn in my side. Do you have any time/energy to hunt this down? If so I'd gladly offer any guidance you need

Do you have any idea what's causing this? I'd like to at least attempt to track this down, but it'd be great to have a starting point.

@AlecAivazis
Copy link
Collaborator

For anyone running into this thread - I reached out to knd on discord where the back and forth is a bit easier 😅

@gschulze
Copy link
Contributor

gschulze commented Nov 6, 2023

Ran into the same issue, making Unit tests effectively non-debuggable. Would be great to have this resolved soon.

@SeppahBaws
Copy link
Collaborator

I put together a minimal reproduction, if anyone wants to attempt to hunt this down :)
https://stackblitz.com/edit/sveltejs-kit-template-default-abiwnx?file=src%2Flib%2FTestComponent.svelte

Simply open the devtools and hit the "fetch data" button. I also found this tool to visualize the sourcemaps, could be useful for debugging this: https://evanw.github.io/source-map-visualization/

@Mtn-View
Copy link
Contributor

Mtn-View commented Oct 29, 2024

Anyone have any pointers if I wanted to take a look? This section where the code is modified without updating the sourcemap seems suspicious to me, but I could be wrong and am not really sure where to go from there. I build the project and messed with it a bit and checked the reproduction above, but I'm not super familiar with sourcemaps so wasn't able to get anything working.

Edit: It seems to be more about the query than the whitespace at the start/end of the script tag, so I guess I'm still looking for advice 😅

@SeppahBaws
Copy link
Collaborator

I dug into this around a month back, this is what I understand is happening so far:

  • we ask svelte's preprocessor for the contents of the script tag
  • this gets passed to recast, which gives us an AST of the script contents
  • we update this AST to what we need
  • since we're now done transforming the file, we ask recast to print the AST back into source code
  • recast also gives us a sourcemap for the script contents, and we pass this forward to svelte/vite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working like it should Core Issues related to the core infrastructure
Projects
None yet
Development

No branches or pull requests

8 participants