Skip to content

feat(processing): Enable Node.js Source Maps #6626

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

Merged
merged 3 commits into from
Dec 21, 2017
Merged

Conversation

kamilogorek
Copy link
Contributor

I still need to add proper tests for this but wanted to make sure that I'm on the right track and my implementation is decent enough.

# therefore we only process user-land frames (starting with /)
# or those created by bundle/webpack internals
if self.data.get('platform') == 'node' and \
not frame.get('abs_path').startswith(('/', 'app:', 'webpack:')):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this is correct? There is no rule about which files might or might not appear in sourcemaps. For react-native i'm pretty sure we saw a bare 'index.bundle' as filename.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot give a definite answer, but I wasn't able to attain any other result than the one above and I tried a lot of variants.

@@ -50,7 +50,7 @@
)
manager.add(43, "user_tracking", "User Tracking", "code", prerequisite=["first_event"])
manager.add(44, "custom_tags", "Custom Tags", "code", prerequisite=["first_event"])
manager.add(45, "source_maps", "Source Maps", "code", prerequisite=["first_event", "javascript"])
manager.add(45, "source_maps", "Source Maps", "code", prerequisite=["first_event", ("javascript", "node")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see

prerequisite=["first_event", ("python", "javascript", "node", "php")]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some feedback here, but this is ultimately @ehfeng's decision:

I'm not sure I'd group node under this feature tracking flag thing. Source maps in node are generally less common and I wouldn't say "required" in the same sense as they are for browser js. And not sure if we'd want to say, using node sourcemaps also toggles this for browser js since I assume setup is going to be entirely different.

Copy link
Contributor

@mattrobenolt mattrobenolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is fine, but I'm really curious how this is going to look on the other end and how raven-node is adapting to send the correct data we need.

Ideally, we're determining if we need sourcemaps from the SDK first, and making sure we tag the payloads correctly so it can be identified. The difference here, which is probably obvious, is that sometimes Node doesn't need it, and sometimes it does. Whereas with JS today, we make strong assumptions that we 100% need additional processing.

Mostly just iterating that the discovery side of things I think needs to happen within the SDK since it'd know easier than the server. Unless you have a better idea for how the whole picture works, I might be thinking of things differently.

@@ -50,7 +50,7 @@
)
manager.add(43, "user_tracking", "User Tracking", "code", prerequisite=["first_event"])
manager.add(44, "custom_tags", "Custom Tags", "code", prerequisite=["first_event"])
manager.add(45, "source_maps", "Source Maps", "code", prerequisite=["first_event", "javascript"])
manager.add(45, "source_maps", "Source Maps", "code", prerequisite=["first_event", ("javascript", "node")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some feedback here, but this is ultimately @ehfeng's decision:

I'm not sure I'd group node under this feature tracking flag thing. Source maps in node are generally less common and I wouldn't say "required" in the same sense as they are for browser js. And not sure if we'd want to say, using node sourcemaps also toggles this for browser js since I assume setup is going to be entirely different.

@mitsuhiko
Copy link
Contributor

@mattrobenolt the way I would like to treat this going forward is that SDK does not determine processing. For some cases we will want to move processing into the relay agent at one point and the less specific config is required to trigger that the better.

@kamilogorek
Copy link
Contributor Author

The main difference between browser JS and node JS is that latter requires both, frame URLs rewrites and manual source maps upload (or using our webpack plugin, as I do now locally – will add it as a doc entry). Where for the browser it can be skipped completely, as we can pull the code and maps from the server (and/or scrape the modules if necessary).

@kamilogorek
Copy link
Contributor Author

I'm not sure if we shouldn't disable scraping for node:

if self.data.get('platform') == 'node':
  self.allow_scraping = False
else:
  self.allow_scraping = self.project.get_option('sentry:scrape_javascript', True)

@kamilogorek
Copy link
Contributor Author

kamilogorek commented Nov 28, 2017

@mitsuhiko I tried to use both tactics, mocking fetch_file and fixtures, but I'm stuck on parsing source maps (without it, I believe it won't move to the branch we need, as token is always None now). It's way over my Python "skills"... ¯\(ツ)

@ghost
Copy link

ghost commented Nov 28, 2017

1 Warning
⚠️ You should update CHANGES due to the size of this PR

Generated by 🚫 danger

@mitsuhiko
Copy link
Contributor

@kamilogorek if you want i can finish the tests

@kamilogorek
Copy link
Contributor Author

kamilogorek commented Nov 28, 2017

That'd be very helpful, thanks @mitsuhiko! I need some assistance delivering this feature.

  • sentry implementation
  • sentry impl. tests
  • docs (in progress)
  • example config using webpack (in progress)
  • required raven-node fixes

Tests are the only thing left now.

@dcramer dcramer merged commit c5d2742 into master Dec 21, 2017
@dcramer
Copy link
Member

dcramer commented Dec 21, 2017

merging and praying per @kamilogorek's request

@dcramer dcramer deleted the nodejs-sourcemaps branch December 21, 2017 22:59
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants