GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support different JS runtimes · Issue #5611 · getsentry/sentry-javascript

Support different JS runtimes #5611

New issue
Copy link
New issue
Copy link
Closed
Closed
Support different JS runtimes#5611
Copy link
Labels
Type: Improvement
Milestone
JS Multiple Runtime Support

Description

@AbhiPrasad
AbhiPrasad
opened on Aug 19, 2022
Issue body actions

Problem Statement

The Sentry SDK should work with WinterCG-compatible runtimes other than NodeJS. We should build new SDKs for these platforms, or figure out how to adapt our Node SDK to fit them.

The spec: https://github.com/wintercg/proposal-common-minimum-api

  • Cloudflare Workers: cloudflare workers support #2484
  • Deno: Support for Deno server #3009
  • Vercel Edge Runtime: Vercel Edge Runtime SDK #8087
  • Next.js middleware support #4206
  • Netlify Edge Functions - Apparently based on Deno
  • Fastly Compute@Edge
  • AWS LLRT
  • WinterJS

There are also other JS runtimes we can take a look at:

  • Bun: Support for Bun #7979

Solution Brainstorm

If you are interested in this, please comment on the individual issues linked above!

Reacted by Onur Temizkan, Aaron Hammer, Luca Forstner, Joon Park, Niklas, Yves Riedener, Varun Arora, Aaron Adams, Bae Junehyeon, Sung Jeon and 9 more

Activity

Next
  1. AbhiPrasad
    added
    Type: Improvement
    Status: Backlog
    on Aug 19, 2022
  2. timfish commented on Sep 9, 2022

    @timfish
    timfish
    on Sep 9, 2022 · Hidden as outdated
    show commentMore actions
  3. timfish commented on Sep 16, 2022

    @timfish
    timfish
    on Sep 16, 2022
    Collaborator
    More actions

    The first step in supporting other runtimes is getting core, hub, types and utils compiling without dom/node types:

    • - Move @sentry/hub code to @sentry/core and keep @sentry/hub as a stub re-exporting types from core so it's not a breaking change
      • ref(hub): Move @sentry/hub code to @sentry/core #5823
    • - getGlobalObject should be replaced with something more universal like this from core-js. globalThis is the global in WinterCG and browsers/node have supported it for a while too
      • feat(utils): Modern implementation of getGlobalObject #5809
      • ref(utils): Remove getGlobalObject() usage from @sentry/utils #5831
      • ref(browser): Remove getGlobalObject() usage from @sentry/browser #5884
      • ref(tracing): Remove getGlobalObject() usage from @sentry/tracing  #5885
      • ref(core): Remove getGlobalObject() usage from @sentry/core #5914
      • ref(utils): Deprecate getGlobalObject as it's no longer used #5949
    • - Remove DOM and node TypeScript lib types from packages that shouldn't be using them
      • Node types can be used in any package #5834
      • ref(typescript): Remove DOM from default lib types #5816

    At this point, core, hub and types are compiling without DOM/node lib types.

    However, utils still requires DOM and node lib types to build successfully.

    To rectify this, all runtime specific code should be moved to the runtime packages:

    • - Move all browser specific code from @sentry/utils to @sentry/browser/utils
      • - Move supportsErrorEvent, supportsDOMError, supportsDOMException, supportsFetch, supportsNativeFetch, supportsReferrerPolicy and supportsHistory to @sentry/browser
      • - Move some functions (like getLocationHref and getDomElement) from browser.ts to @sentry/browser
      • - Move everything in instrument.ts to @sentry/browser
        • ❌ This is an issue due to addInstrumentationHandler usage in tracing
    • - Move all node specific code from @sentry/utils to @sentry/node
      • - Move everything in node.ts to @sentry/node
        • ❌ Moving dynamicRequire is an issue since it's used in tracing

    The above can done without technically making breaking changes since we make no guarantees about @sentry/utils, but it will impact downstream SDKs that make use of some of the moved functions.

    The major downside to moving these utilities to the browser/node packages and exporting them at the root is that they would become public API methods (for downstream SDKs to use) and with that comes stability guarantees.

    It would be less of a maintenance headache to either:

    • Move them to new packages (like @sentry/browser-utils) or package export (@sentry/browser/utils)
    • Wrap them in an internal object export that we make no stability promises about

    @sentry/tracing

    There are a few issues above where @sentry/tracing relies on code from @sentry/utils which will get moved to browser/node. This will result in tracing depending on both browser/node. This can further be fixed by splitting the tracing code #5815.

    Reacted by Steven Eubank
  4. AbhiPrasad
    assigned
    timfish
    on Sep 23, 2022
  5. AbhiPrasad
    added a commit that references this issue on Sep 26, 2022

    feat(utils): Modern implementation of `getGlobalObject` (#5809)

    a5bfa80
  6. AbhiPrasad
    added this to the JS Multiple Runtime Support milestone on Sep 26, 2022
  7. lforst commented on Sep 26, 2022

    @lforst
    lforst
    on Sep 26, 2022
    Contributor
    More actions

    How about having these as named exports? @sentry/tracing, @sentry/tracing/browser and @sentry/tracing/node?

    Shouldn't it be @sentry/browser/tracing instead of @sentry/tracing/browser? So we can depend on @sentry/browser from within @sentry/browser/tracing. Maning the tracing submodule in @sentry/browser is just an extension of @sentry/browser. (I worded that kinda confusing but I think it gets the point across).

    Also, I'd just have all tracing functionality in @sentry/node by default, so there wouldn't be any need for @sentry/node/tracing.

    Reacted by Tim Fish and Varun Arora
  8. timfish commented on Sep 26, 2022

    @timfish
    timfish
    on Sep 26, 2022
    Collaborator
    More actions

    Yep, I need to update the above ramblings.

    There's a more recent issue for the tracing changes.

    Also, I'd just have all tracing functionality in @sentry/node by default, so there wouldn't be any need for @sentry/node/tracing.

    Would we want to add all the hub extensions by default too?

    We wouldn't want to run _autoloadDatabaseIntegrations in the Electron SDK because it hits app startup time significantly!

  9. lforst commented on Sep 26, 2022

    @lforst
    lforst
    on Sep 26, 2022
    Contributor
    More actions

    Continued thread over in more recent issue here: #5815 (comment)

  10. AbhiPrasad
    changed the title [-]Support different JS runtimes[/-] [+]WinterCG - Support different JS runtimes[/+] on Oct 5, 2022
  11. AbhiPrasad commented on Oct 7, 2022

    @AbhiPrasad
    AbhiPrasad
    on Oct 7, 2022
    ContributorAuthor
    More actions

    We had a discussion internally about the global object changes - @timfish could we look into if we can just use globalThis?

  12. timfish commented on Oct 7, 2022

    @timfish
    timfish
    on Oct 7, 2022
    Collaborator
    More actions

    could we look into if we can just use globalThis?

    Eventually, but we'll need to wait for Node.js v12 to be our MSV.

    image

    And the Sentry supported browsers suggests we need to support Android 4.4 and IE10/11 so these would need to be polyfilled.

    image

    That means we can probably remove the window and self lines from this:

    sentry-javascript/packages/utils/src/global.ts

    Lines 56 to 65 in 8570f0d

    const GLOBAL =
    (typeof globalThis == 'object' && isGlobalObj(globalThis)) ||
    // eslint-disable-next-line no-restricted-globals
    (typeof window == 'object' && isGlobalObj(window)) ||
    (typeof self == 'object' && isGlobalObj(self)) ||
    (typeof global == 'object' && isGlobalObj(global)) ||
    (function (this: any) {
    return this;
    })() ||
    {};

  13. lobsterkatie commented on Oct 7, 2022

    @lobsterkatie
    lobsterkatie
    on Oct 7, 2022
    Member
    More actions

    LOL

    image

    Looks like we haven't updated this page in quite a long time. (EDIT: Heh. Turns out July-me already discovered that: getsentry/sentry-docs#5351)

    I can say for sure we don't need to worry about Android 4.4. I did a quick google, and the first version which can handle, for example, object spread is Android 8. For IE11, we've already told people that they have to use one of our ES5 bundles, to which we could add a polyfill if necessary. But the Node 10 business is definitely a bigger blocker. I like your idea of at least removing the browser-specific parts.

  14. AbhiPrasad commented on Oct 13, 2022

    @AbhiPrasad
    AbhiPrasad
    on Oct 13, 2022
    ContributorAuthor
    More actions

    We merged in #5831, could we rebase the rest of the PRs @timfish?

    Reacted by Tim Fish
  15. 4 remaining items

  16. KrisBraun commented on May 7, 2023

    @KrisBraun
    KrisBraun
    on May 7, 2023
    More actions

    🤞 for Cloudflare Pages support, which should be nearly identical to Cloudflare Workers, just with different handlers.

    Reacted by Ollie W
  17. github-actions
    added
    Waiting for: Team
    on May 7, 2023
  18. lforst commented on May 8, 2023

    @lforst
    lforst
    on May 8, 2023
    Contributor
    More actions

    @KrisBraun Gonna happen soon™ 👀

    Reacted by Kris Braun, Cole Sanderson, Nico Schett and Ollie W
    Reacted by Wendell Misiedjan and Ollie W
    Reacted by Kevin Kipp, Varun Arora, Cole Sanderson, Wendell Misiedjan and Ollie W
  19. github-actions
    removed
    Waiting for: Team
    on May 8, 2023
  20. hubertdeng123
    removed
    Status: Backlog
    on Jul 26, 2023
  21. huw commented on Jul 31, 2023

    @huw
    huw
    on Jul 31, 2023
    More actions

    I’ve updated my Cloudflare Workers Gist for Toucan v3.2.0 and Remix v2. It’s a lot more complicated & hacky now thanks to Remix v2, but still very possible. Please reply there if you have any questions :)

  22. getsantry
    added
    Waiting for: Product Owner
    on Jul 31, 2023
  23. getsantry
    added this to GitHub Issues with 👀on Jul 31, 2023
  24. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀on Jul 31, 2023
  25. Lms24
    removed
    Waiting for: Product Owner
    on Aug 3, 2023
  26. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Aug 3, 2023
  27. AbhiPrasad
    added a commit that references this issue on Apr 2, 2024

    feat(utils): Use `globalThis` (#11351)

    ed4a751
  28. cadesalaberry
    added a commit that references this issue on Apr 19, 2024

    feat(utils): Use `globalThis` (getsentry#11351)

    9259c01
  29. AbhiPrasad commented on Aug 2, 2024

    @AbhiPrasad
    AbhiPrasad
    on Aug 2, 2024
    ContributorAuthor
    More actions

    With @sentry/cloudflare being available in 8.22.0 and us having SDKs for @sentry/vercel-edge, @sentry/bun, @sentry/deno + exposing a bunch of APIs via @sentry/core, I think we can close this issue - we support every major non-node runtime, and we have all the building blocks via generic JS APIs in the SDKs for you to support any custom runtime you wish.

    The one's left on the list are:

    • Netlify Edge Functions
    • Fastly Compute@Edge
    • AWS LLRT
    • WinterJS

    but right now these are not high priority for us. We'll tackle them slowly over the next couple quarters (PRs are always welcome though!)

    Reacted by psytrx
    Reacted by psytrx
    Reacted by Mosaad, psytrx and Varun Arora
  30. AbhiPrasad
    closed this as completedon Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Improvement

    Projects

    • GitHub Issues with 👀
      Status
      No status
      Show more project fields

    Milestone

    • JS Multiple Runtime Support

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.