Skip to content

Remix SDK invariant is not captured as Issue  #5362

Closed

Description

@moishinetzer

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/remix

SDK Version

7.5.0

Framework Version

7.5.0

Link to Sentry event

https://sentry.io/organizations/netzerorg/performance/trace/7a8e8c962aa242aabb565917ff0c891c/

Steps to Reproduce

import invariant from "tiny-invariant";

export const loader: LoaderFunction = async ({ params }) => {
  const user = params["*"];
  invariant(user, "user is required");
  const user= await getUser({ user: user});
  return json({
    user,
  });
};

Now, navigate to a route where the user does not exist.

Expected Result

Invariant is triggered and thrown and an issue is created in sentry dashboard

Actual Result

Invariant is triggered and thrown, however sentry only receives a transaction and doesn't flag it as an issue.

Activity

  1. moishinetzer commented on Jul 5, 2022

    @moishinetzer
    Author

    Note: As a sidepoint I am also getting every 10 seconds an actual issue with the following information:

    Sentry event: issues/3402471265 (Same org as specified in issue)

    /myapp/node_modules/@remix-run/server-runtime/data.js

    Object.captureException
    {"size":0}

    76.   try {
    77.    result = await loader({
    78.      request: stripDataParam(stripIndexParam(request)),
    79.      context: loadContext,
    80.      params: match.params
    81.    });
    82.  } catch (error) {
    83.    if (!responses.isResponse(error)) {
    84.      throw error; 
  2. added this to the Sentry Remix SDK milestone on Jul 5, 2022
  3. AbhiPrasad commented on Jul 5, 2022

    @AbhiPrasad
    Contributor

    Hey thanks for writing in. @onurtemizkan mind taking a look when you get some time to help triage this?

  4. moishinetzer commented on Jul 6, 2022

    @moishinetzer
    Author

    My project is now seeing several issues. feel free to reach out to me or look around on my account to see them. None of them have been caused by actual user related issues and seem to be the SDK.

  5. AbhiPrasad commented on Jul 6, 2022

    @AbhiPrasad
    Contributor

    There's some RangeError: Maximum call stack size exceeded which we should look at.

    RangeError: Maximum call stack size exceeded
      File "/myapp/node_modules/@sentry/src/misc.ts", line 143, col 1, in Object.addExceptionMechanism
      File "/myapp/node_modules/@sentry/remix/cjs/utils/instrumentServer.js", line 45, col 17, in <anonymous>
      File "/myapp/node_modules/@sentry/src/scope.ts", line 515, col 1, in <anonymous>
      File "/myapp/node_modules/@sentry/src/syncpromise.ts", line 58, col 1, in new SyncPromise
      File "/myapp/node_modules/@sentry/src/scope.ts", line 510, col 1, in Scope._notifyEventProcessors
      File "/myapp/node_modules/@sentry/src/scope.ts", line 527, col 1, in <anonymous>
      File "/myapp/node_modules/@sentry/src/syncpromise.ts", line 58, col 1, in new SyncPromise
      File "/myapp/node_modules/@sentry/src/scope.ts", line 510, col 1, in Scope._notifyEventProcessors
      File "/myapp/node_modules/@sentry/src/scope.ts", line 527, col 1, in <anonymous>
      File "/myapp/node_modules/@sentry/src/syncpromise.ts", line 58, col 1, in new SyncPromise
    

    There seems to be problems with adding the event processor, but not sure what's causing it 🤔

  6. 16 remaining items

  7. AbhiPrasad commented on Jul 8, 2022

    @AbhiPrasad
    Contributor

    @moishinetzer thank you so much for helping us debug this and giving detailed info. We would love to send you some Sentry swag for helping us out, can we reach out through the email in your profile?

  8. moishinetzer commented on Jul 8, 2022

    @moishinetzer
    Author

    @moishinetzer thank you so much for helping us debug this and giving detailed info. We would love to send you some Sentry swag for helping us out, can we reach out through the email in your profile?

    Absolutely please do! I have a question for you as well and would love to be in touch! Loving the Sentry team you guys are awesome!

    In the meantime I'm going to try out the above change and update you accordingly.

  9. moishinetzer commented on Jul 8, 2022

    @moishinetzer
    Author

    locally the unhandled issue now does not appear. however since I'm not sure how to apply the changes to my deployed version, I haven't been able to check there yet.

  10. AbhiPrasad commented on Jul 8, 2022

    @AbhiPrasad
    Contributor

    Absolutely please do! I have a question for you as well and would love to be in touch! Loving the Sentry team you guys are awesome!

    Will reach out :)

    locally the unhandled issue now does not appear. however since I'm not sure how to apply the changes to my deployed version, I haven't checked there yet.

    We'll cut another release of the SDK by end of day eastern timezone, hopefully that'll help you test. If this does fix the unhandled issue - we only have the Maximum call stack size exceeded to investigate. Hopefully that should be solved as well!

  11. AbhiPrasad commented on Jul 8, 2022

    @AbhiPrasad
    Contributor
  12. moishinetzer commented on Jul 10, 2022

    @moishinetzer
    Author

    Ok so here's a quick update re my project:

    • The maximum call stack issue is resolved!

    However for some reason the issue of
    https://sentry.io/organizations/netzerorg/issues/3413500624/?query=is%3Aunresolved

    Object.captureException:
    {"size":0}

    has been triggering exactly every 10 seconds.


    Interesting to note, whenever the invariant issue is triggered as shown in the initial issue, the following shows both when tested locally and deployed.

    ReferenceError: name is not defined
        at /myapp/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:65:40
        at handleDocumentRequest (/myapp/node_modules/@remix-run/server-runtime/server.js:400:18)
        at requestHandler (/myapp/node_modules/@remix-run/server-runtime/server.js:49:18)
        at /myapp/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:134:16
        at /myapp/node_modules/@remix-run/express/server.js:39:22

    And also whenever I trigger the above error it does not get sent to sentry. Either due to it not being triggered or either due to the fact that this and the above issue are related. I'm inclined to think it's not sent as it does not show in the issue logs when I look for it after triggering it.

    On a quick glance this may seem to be a similar issue to #5401

    Let me know if there's any other kind of testing I can do to help this issue out!

  13. moishinetzer commented on Jul 10, 2022

    @moishinetzer
    Author

    Super quick update, after further research it seems that #5401 (comment) is definitely what the ReferenceError: name is not defined error is about.

    After patching locally not only did the name error go away, the invariant triggers in sentry correctly!

    image

    My changes:

        try {
          const span = activeTransaction.startChild({
            op: 'remix.server.documentRequest',
            description: activeTransaction.name,
            tags: {
              method: request.method,
              url: request.url,
            },
          });
    
          res = await origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
    
          span.finish();
        } catch (err) {
    --      captureRemixServerException(err, name);
    ++      captureRemixServerException(err, 'loader');
          throw err;
        }

    I'm going to try test this out on the deployed version and update this comment accordingly. Fingers crossed!

    Update:

    After applying the above change to the deployed version the ReferenceError: name is not defined error does not show and the invariant gets sent correctly as an issue so it's the same result as local!

    However the issue mentioned earlier Object.captureException still remains.

  14. onurtemizkan commented on Jul 11, 2022

    @onurtemizkan
    Contributor

    Thanks @moishinetzer,
    So, {size: 0} error every 10 seconds might be because of this: https://fly.io/docs/reference/configuration/#services-http_checks.

    Looks like another case to handle in the SDK, will get back to you.

  15. onurtemizkan commented on Jul 11, 2022

    @onurtemizkan
    Contributor

    Update:

    So, {size: 0} error every 10 seconds might be because of this: https://fly.io/docs/reference/configuration/#services-http_checks.

    The source of this one is:

      if (!user) {
        throw redirect("/page");
      }
    

    The redirect response is thrown every 10 seconds from the GET request to root.
    Opened a PR: #5405

  16. moishinetzer commented on Jul 11, 2022

    @moishinetzer
    Author

    Just tested out the latest commit and it seems that all problems mentioned in this issue beginning to end have been resolved!

    I'll test out the release when it comes out and assuming all's fine I'll close the issue.

    Thanks so much @AbhiPrasad @onurtemizkan for all your hard work on this. And ridiculously fast respond time! 👏

  17. AbhiPrasad commented on Jul 15, 2022

    @AbhiPrasad
    Contributor

    Fix released with 7.7.0! 🚀

  18. AbhiPrasad commented on Jul 28, 2022

    @AbhiPrasad
    Contributor

    @moishinetzer I reached out through email - wanted to confirm if you had gotten it?

  19. moishinetzer commented on Jul 28, 2022

    @moishinetzer
    Author

    @AbhiPrasad yes, received! Just saw it now thanks for the bump!!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions