question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@backstage/plugin-cost-insights 0.11.13 fails to load correctly in tests

See original GitHub issue

Expected Behavior

Upgrading @backstage/plugin-cost-insights should not cause any issues.

Current Behavior

Upgrading @backstage/plugin-cost-insights from 0.11.12 to 0.11.13 causes test suite failure, with the error:

TypeError: Cannot read property 'default' of undefined

      1 | import * as luxon from 'luxon';
    > 2 | import { Duration } from '@backstage/plugin-cost-insights';
        |                           ^
      3 | import { DEFAULT_COST_DATE_FORMAT } from './format';
      4 | import { assertNever } from './assert';
      5 |

      at ../../../node_modules/node_modules/react-dom/cjs/react-dom.development.js:18:13
      at Object.<anonymous> (../../../node_modules/node_modules/react-dom/cjs/react-dom.development.js:25011:4)
      at Object.<anonymous> (../../../node_modules/@backstage/plugin-cost-insights/dist/index.esm.js:1:348)
      at Object.<anonymous> (utils/duration.ts:2:27)
      at Object.<anonymous> (clients/costInsights/dummyUtils.ts:23:17)
      at Object.<anonymous> (clients/costInsights/costInsightsClient.ts:14:19)
      at Object.<anonymous> (clients/costInsights/costInsightsClient.test.ts:3:27)

While the tests fail, the build itself succeeds, and the application can run without any errors.

Possible Solution

It looks like in commit https://github.com/backstage/backstage/commit/be32bc3edbe758dd864f829142023904ba65944a, react-dom was removed from the dependencies in plugins/cost-insights/package.json.

Looking at the dependency tree, there are multiple sub-dependencies of this plugin that require react-dom as a peer. I am by no means an expert on peer dependencies, but it is my understanding that not re-declaring transitive peer dependencies can sometimes cause issues.

My best guess is that there are some resolution issues happening when using ts-node (via the backstage-cli), since the issue only occurs during testing, and not while the application is actually running (when ts-node is no longer in the picture).

One other thing I noticed, though I don’t think it is the cause of this issue, is that some of the downstream dependencies for the @backstage/plugin-cost-insights plugin have peerDependencies requirements for React v15/v16, meaning that if v17 were to actually be used, it would potentially have errors, as it does not match downstream peer dependencies.

Steps to Reproduce

  1. Update @backstage/plugin-cost-insights from 0.11.12 to 0.11.13
  2. Run test on files that import anything from the plugin (3 separate test files are failing, all with the same error, importing different parts of the plugin).

Context

  • Originally trying to do a version bump with backstage-cli versions:bump. Narrowed the problem down to just the one plugin.
  • When the plugin is updated, no other entry in the yarn.lock is changed, as the new plugin dependencies are already present from other plugins.
  • react-dom is installed in the app, and yarn why shows only one version is installed (react-dom@16.14.0).

Your Environment

  • NodeJS Version (v14): v14.17.6
  • Operating System and Version (e.g. Ubuntu 14.04): Linux 5.4.0-1063-azure - linux/x64
  • Browser Information: N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Rugvipcommented, Dec 27, 2021

TL;DR: all of @backstage/test-utils was being built into the published package. Bit more details in the fix: #8644

0reactions
Rugvipcommented, Dec 27, 2021

I’m afraid it’s a bit too late to unpublish at this point, but I added deprecation messages for the two broken releases

Read more comments on GitHub >

github_iconTop Results From Across the Web

@backstage/plugin-cost-insights - npm
A Backstage plugin that helps you keep track of your cloud spend. ... Start using @backstage/plugin-cost-insights in your project by running ...
Read more >
backstage/plugin-cost-insights
API Reference for @backstage/plugin-cost-insights. ... @backstage/plugin-cost-insights. A Backstage plugin that helps you keep track of your cloud spend ...
Read more >
@backstage/plugin-techdocs-node: Versions | Openbase
Full version history for @backstage/plugin-techdocs-node including change logs. ... It allows you to load a template from a local directory, edit it with...
Read more >
backstage/backstage v1.0.0 on GitHub - NewReleases.io
New release backstage/backstage version v1.0.0 on GitHub. ... 1f2757b: BREAKING: The useEntity hook no longer returns loading or error states, ...
Read more >
Untitled
1 franc 1948 value, Lainox four, Veneto wikipedia economia, ... Chantal sobhraj wife, Burdwan university exam results, Auto karta selce, Best tech trance ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found