honeybadger-io / honeybadger-js

Universal JavaScript library for reporting errors to Honeybadger.io :zap:
https://www.honeybadger.io/for/javascript/
MIT License
109 stars 62 forks source link

Thousands of errors occur when @honeybadger-io/js is installed in a Next.js project #1320

Open GabeMeister opened 6 months ago

GabeMeister commented 6 months ago

What are the steps to reproduce this issue?

  1. Create a Next.js app with Next 14
  2. Run through the steps to install honeybadger within a Next.js project here.
  3. Also run yarn add @honeybadger-io/js to add honeybadger's js package
  4. Create an error on the page, and observe a ton of errors showing up in Honeybadger when Honeybadger goes to run client.notify() in the browser.

What happens?

For Next.js projects, the docs only say to install @honeybadger-io/react and @honeybadger-io/nextjs npm packages, it subtly leaves off @honeybadger-io/js. However, to someone who's new to Honeybadger and getting it setup, this can be often be missed and assumed the @honeybadger-io/js package should also be installed (Next.js and React is all JavaScript after all, right?). However, when this package is installed and it's not the same version, we got a lot of very confusing errors, and ended up needing to pay extra since we exceeded our error quota for our package (over 100,000 errors). My theory is that when we are importing Honeybadger from @honeybadger-io/jsit's importing from the wrong npm module version, and it causes a problem.

What were you expecting to happen?

No errors occur, or the Honeybadger package gives us a big warning saying we need to uninstall the @honeybadger-io/js package.

Any logs, error output, etc?

Our app got over 100,000 errors in a span of 24 hours, with an exception message that says UnhandledPromiseRejectionWarning: Object Not Found Matching Id:5, MethodName:update, ParamCount:4.

What versions are you using?

Operating System: Fly.io app running on Alpine Linux v3.19, browser running on Ubuntu 23.03 Package Name: @honeybadger-io/js, @honeybadger-io/react, @honeybadger-io/nextjs Package Version: "@honeybadger-io/js": "^6.2.0", "@honeybadger-io/nextjs": "^5.8.12", "@honeybadger-io/react": "^6.1.8", Browser Version: Chrome 122.0.6261.94

subzero10 commented 6 months ago

Hey @GabeMeister, I'm sorry that you had this experience while setting up Honeybadger for the first time.

we got a lot of very confusing errors, and ended up needing to pay extra since we exceeded our error quota for our package (over 100,000 errors).

If this happens again, don't hesitate to reach out to our support (support@honeybadger.io) and we'll help you out with your error quota, even more so when the root cause is on our side! cc @stympy @joshuap

the Honeybadger package gives us a big warning saying we need to uninstall the @honeybadger-io/js package.

The issue here is not that you have to uninstall the @honeybadger-io/js package. The package is a required dependency of the @honeybadger-io/nextjs package and it's mentioned at the top of the docs. Usually npm (or yarn) will stop you from installing dependencies that are not compatible. What happened here is that a breaking change was introduced between the js and nextjs packages and the peerDependencies of the nextjs package were not updated to protect from such issues. We use Lerna for package versioning in this monorepo which does not make any changes to peerDependencies automatically. Hence, we tend to manually update them when we have major version releases, but once in a while we might get into a situation such as the one you faced.

I will update the minimum version of the js. package inpeerDependencies of the nextjs package and that way npm (or yarn) will tell you if the dependencies are not compatible.

Before I do that though, can you please clarify which version of @honeybadger-io/js, @honeybadger-io/nextjs and @honeybadger-io/react you have running now?