digitalcredentials / security-document-loader

A common documentLoader for DCC JSON-LD using libraries.
MIT License
0 stars 2 forks source link

Production Build "Uncaught TypeError: Cannot convert undefined or null to object" On Page Load #4

Closed watermelonjam closed 3 weeks ago

watermelonjam commented 1 year ago

Stack trace below; it's pretty opaque since this issue only occurs in production builds. Inspection of the stack trace shows the origination from security-document-loader index.ts:

export { securityLoader, httpClientHandler } from './documentLoader'

The call stack flows down to whatwg-url version 11.0.0 utils.js (which seems to be a generated file). The offending line:

const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);

Angular CLI encountered a problem with this statement in their own code a couple of years ago, and there is apparently a solution. Not sure if what's required is a request for a patch on whatwg-url or if there's a possbile workaround in this project.

Stack trace:

utils.js:34 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at 6180 (utils.js:34:39)
    at __webpack_require__ (bootstrap:19:32)
    at 4951 (URL.js:4:15)
    at __webpack_require__ (bootstrap:19:32)
    at 9068 (webidl2js-wrapper.js:3:13)
    at __webpack_require__ (bootstrap:19:32)
    at 9645 (index.js:3:34)
    at __webpack_require__ (bootstrap:19:32)
    at 7223 (DidWebResolver.js:11:17)
6180 @ utils.js:34
__webpack_require__ @ bootstrap:19
4951 @ URL.js:4
__webpack_require__ @ bootstrap:19
9068 @ webidl2js-wrapper.js:3
__webpack_require__ @ bootstrap:19
9645 @ index.js:3
__webpack_require__ @ bootstrap:19
7223 @ DidWebResolver.js:11
__webpack_require__ @ bootstrap:19
1872 @ index.js:5
__webpack_require__ @ bootstrap:19
8630 @ documentLoader.ts:18
__webpack_require__ @ bootstrap:19
8514 @ index.ts:4
__webpack_require__ @ bootstrap:19
(anonymous) @ index.tsx:55
(anonymous) @ index.js:38
(anonymous) @ index.js:38
watermelonjam commented 1 year ago

Now that I look closer, it's the security loader dependency on @interop/did-web-resolver that starts the fireworks. DidWebResolver.js:11: var whatwgUrl = require('whatwg-url');. Our application code was converted to use did:web instead of did:key, which re-introduced this issue.

dmitrizagidulin commented 1 year ago

(Looking into this)

temitope commented 1 year ago

I am seeing the same error (same line of same file utils.js:34 at least) in React Native (expo)

image
dmitrizagidulin commented 1 year ago

@watermelonjam - I vaguely recall you ended up fixing this by making a PR to an upstream lib? Which versions did you end up going with?

alexfigtree commented 6 months ago

@watermelonjam Could you please confirm and let us know if you're still having this issue?

alexfigtree commented 3 weeks ago

@watermelonjam We've fixed this in our current version, please re-open if still an issue.