inrupt / inrupt/solid-client-authn-js

Error inside of getWebidFromTokenPayload when using node 16

Open
#3,004 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
77
Forks
49
Avg merge
18h 20m
Merged PRs (30d)
32

Description

Impacted package

Which packages do you think might be impacted by the bug ?

  • solid-client-authn-browser
  • solid-client-authn-node
  • solid-client-authn-core
  • oidc-client-ext
  • Other (please specify): ...
Bug description

This only happens with node 16, pinning node to 18 solves the problem in our case

To Reproduce

@jeswr it might be a bit complicated, but I'm available for a LiveShare session in (VScode) to show it in the debugger using my local setup.

https://github.com/janeirodigital/sai-js

  1. start CSS in css-storage-fixture package
  2. start redis docker run --name sai-redis -p 6379:6379 -d redis
  3. start the service in service package with yarn debug
  4. attach to the process with the debugger and set to break on exceptions
  5. start the frontend https://github.com/elf-pavlik/sai-impl-web
  6. open http://localhost:4200 and Login into the frontend
  7. click Connect Server to Login into the backend/service
Expected result

Solid-OIDC OP should redirect to the backend

Actual result

The backend is not responding so the redirect is pending

Environment

Please run

npx envinfo --system --npmPackages --binaries --npmGlobalPackages --browsers

in your project folder and paste the output here:

$ npx envinfo --system --npmPackages --binaries --npmGlobalPackages --browsers


  System:
    OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 24.33 GB / 31.24 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 16.20.1 - ~/.volta/tools/image/node/16.20.1/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.19.4 - ~/.volta/tools/image/node/16.20.1/bin/npm
  npmPackages:
    @janeirodigital/sai-api-messages: ^0.10.0 => 0.10.0 
  npmGlobalPackages:
    corepack: 0.17.0
    npm: 8.19.4

Additional information

Looking at the call stack it looks that errors inside of getWebidFromTokenPayload -> fetchJwks in @inrupt/solid-client-authn-core

Exception has occurred: TypeError: ReadableStream.prototype.pipeTo's first argument must be a WritableStream
  at ReadableStream.pipeTo (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/web-streams-ponyfill/dist/polyfill.js:1681:29)
    at ReadableStream.pipeThrough (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/web-streams-ponyfill/dist/polyfill.js:1669:26)
    at fetchFinale (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/lib/fetch/index.js:973:52)
    at mainFetch (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/lib/fetch/index.js:773:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
pipeTo (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/web-streams-ponyfill/dist/polyfill.js:1681)
pipeThrough (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/web-streams-ponyfill/dist/polyfill.js:1669)
fetchFinale (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/lib/fetch/index.js:973)
mainFetch (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/lib/fetch/index.js:773)
processTicksAndRejections (internal/process/task_queues:96)
async function (Unknown Source:0)
fetching (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/lib/fetch/index.js:517)
fetch (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/lib/fetch/index.js:245)
fetch (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/undici/index.js:107)
fetchJwks (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/@inrupt/solid-client-authn-core/dist/index.js:71)
getWebidFromTokenPayload (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/@inrupt/solid-client-authn-core/dist/index.js:85)
handle (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/@inrupt/solid-client-authn-node/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js:79)
async function (Unknown Source:0)
handle (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/@inrupt/solid-client-authn-core/dist/index.js:55)
processTicksAndRejections (internal/process/task_queues:96)
async function (Unknown Source:0)
ClientAuthentication.handleIncomingRedirect (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/@inrupt/solid-client-authn-node/dist/ClientAuthentication.js:57)
Session.handleIncomingRedirect (/home/elf-pavlik/code/solid/sai/sai-js/node_modules/@inrupt/solid-client-authn-node/dist/Session.js:57)
handleAsync (/home/elf-pavlik/code/solid/sai/sai-js/packages/service/src/handlers/login-redirect-handler.ts:28)
processTicksAndRejections (internal/process/task_queues:96)

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

Reproduce the failure on Node 16 using the listed CSS, Redis, service, and frontend setup, then compare with Node 18. Start at packages/service/src/handlers/login-redirect-handler.ts and follow the reported getWebidFromTokenPayload and fetchJwks path in solid-client-authn-core; done means the backend completes the Solid-OIDC redirect without the ReadableStream error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.