Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Type error with newest node version 19.6.1 due to update of undici to version 5.19.1 #10118

Closed
lukas-warrify opened this issue Feb 20, 2023 · 1 comment
Labels

Comments

@lukas-warrify
Copy link

lukas-warrify commented Feb 20, 2023

What version of React Router are you using?

6.8.1

Steps to Reproduce

In all our components, which are using react-router, if we run tests using the latest node version 19.6.1, we get a type error. This is most likely due to an update of the undici dependency to version >=5.19.0 (see nodejs/undici@7615308 for further information).

E.g. we have a simple component which just has a button redirecting to a sign up page:

  const handleProceedSignUp = React.useCallback(() => {
    navigate(
      {
        pathname: "/sign-up",
        search: location.search,
      },
      { state: location.state }
    );
  }, [navigate, location]);

Expected Behavior

No type errors are raised.

Actual Behavior

Upon running tests with components that use navigate, I get the following error:

TypeError: The "emitter" argument must be an instance of EventEmitter or EventTarget. Received an instance of AbortSignal
❯ new NodeError node:internal/errors:399:5
❯ getEventListeners node:events:913:9
❯ new Request node:internal/deps/undici/undici:7132:17
❯ createClientSideRequest ../node_modules/@remix-run/router/router.ts:3214:10
❯ startNavigation ../node_modules/@remix-run/router/router.ts:1144:19
❯ Object.navigate ../node_modules/@remix-run/router/router.ts:1039:18
❯ push ../node_modules/react-router/lib/components.tsx:75:16
❯ navigate ../node_modules/react-router/lib/hooks.tsx:212:7

@timdorr
Copy link
Member

timdorr commented Feb 20, 2023

Thanks, but this isn't a bug with React Router. undici types the signal prop as accepting an AbortSignal, so we are using the correct typing. The problem is caused by nodejs/undici#1910, which calls getEventListeners and that API doesn't accept the AbortSignal type.

This needs to be fixed upstream.

@timdorr timdorr closed this as completed Feb 20, 2023
vimto added a commit to Greater-Wellington-Regional-Council/Environmental-Outcomes-Platform that referenced this issue Mar 31, 2023
Due to react-router incompatibility with nodejs version: remix-run/react-router#10118 (comment)
vimto added a commit to Greater-Wellington-Regional-Council/Environmental-Outcomes-Platform that referenced this issue Apr 4, 2023
* Clean up imports
- Remove `import React from 'react'` as it's no longer needed
- Add import type qualifier where only type info is needed

* Move git sha debug output to HTML Meta tag

* Add default for optional Button prop

* Standardise function export style

* Add and configure eslint and run in new npm check script as part of CI

* Fix lint warnings

* Ensure QueryClientProvider is present in tests to prevent Errors

* Exit on error in CI script

* Force lint output to be coloured for CI

* Fixed broken tests

Due to react-router incompatibility with nodejs version: remix-run/react-router#10118 (comment)

* Add recommended  lint libraries and fix errors

* Install and configure msw to prevent test errors

* Only use inline type import when needed since it's more verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants