rollbar / rollbar/rollbar-react

Cannot read properties of undefined (reading 'context')

Open
#102 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
46
Forks
9
Avg merge
2d 56m
Merged PRs (30d)
4

Description

I'm trying to use RollbarContext and it's giving me an error on its componentDidMount function as it's trying to access rollbar.options.payload.context (see here). Looking at the rollbar.options object, there's no payload.

image

This is how I'm using the <RollbarContext>:


const rollbarConfig = {
  accessToken: '<token>',
  environment: 'testenv',
};
...
    <Provider config={rollbarConfig}>
       <ErrorBoundary>
        <Router>
          <Route path={rootPath}>
            <Switch>
              {Object.entries(routes).map(([path, route]) => {
                return (
                  <RollbarContext context={path}>
                    <LazyRoute ... />
                  </RollbarContext>
                );
              })}
              <Redirect from="*" to="/app/404" />
            </Switch>
          </Route>
        </Router>
      </ErrorBoundary>
    </Provider>

I'm using the following versions of the libraries:

  • rollbar@2.26.2
  • @rollbar/react@0.11.2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/rollbar-context.js at componentDidMount, then compare its access to rollbar.options.payload.context with the reported rollbar@2.26.2 and @rollbar/react@0.11.2 setup. Reproduce the failure using the shown Provider and RollbarContext structure; done means mounting RollbarContext no longer throws when the reported configuration is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.