"Error: can't serialize object of unregistered class" in cypress
mapbox-gl-js version: 1.0.0
cypress version 3.3.1/3.3.0 - ref: https://github.com/cypress-io/cypress/issues/4322
browser: Electron 61
Steps to Trigger Behavior
- Minimal repro available here: https://github.com/pburkindine/mapboxgl-electron/
- run
npm run startandnpm run cy - cypress test will fail; click on failed XHR calls to see stack trace
- Does not occur in Chrome testing with cypress
- Does not occur in Electron without cypress (e.g., in electron in cypress,
window.location.href="http://localhost:8080"twice) - Does not occur in normal use
- Class in question appears to be ArrayBuffer
Link to Demonstration
https://github.com/pburkindine/mapboxgl-electron/
Expected Behavior
Cypress test should succeed
Actual Behavior
Cypress test fails with error "Error: can't serialize object of unregistered class" in the mapbox webworker
Hi, sorry you're having trouble. Can you confirm whether or not this worked before, and what version combo (mapbox-gl-js version, cypress version, electron version)?
We fixed an issue in the past with Chrome that sounded similar, but I don't think we've regressed that fix. Lemme know if this helps you (fix was related to thrown Error type on a request abort).
If you can confirm (or deny, that's fine) a version combo that used to work I'd be happy to look into this further.
@ahk thanks, I did see that issue, but not sure if it's related.
I was able to bisect, the repro works fine w/ cypress 3.3.1/electron 61/mapbox 0.52.0 and not with 0.53.0
(maybe worth mentioning that mapbox is pulled from the cdn in public/index.html, not from node_modules, in the repro)
@ahk just checking on this one
I've been experiencing this issue myself, and have taken a look:
The web worker's serialize function currently checks for ArrayBuffers like so:
https://github.com/mapbox/mapbox-gl-js/blob/94598e70cffbcf239c76259da6351f751062fcc2/src/util/web_worker_transfer.js#L129
However any cypress ArrayBuffer is not guaranteed to test true with instanceof ArrayBuffer, as cypress and many of the packages used by cypress do not test for ArrayBuffer with exclusively instanceof, for the reasons described here. They favour solutions such as:
// ArrayBuffers from another context (i.e. an iframe) do not pass the instanceof check
// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
function isArrayBuffer (obj) {
return obj instanceof ArrayBuffer ||
(obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
typeof obj.byteLength === 'number')
}
I suggest the ArrayBuffer test is updated to account for this. ~~Happy to work on a PR for this.~~
EDIT: Taken a closer look, this might not be so simple due to the static typing. I'm unfamiliar with Flow, and don't know where to proceed from here.
@ahk bump
@anthony-hull is this issue resolved?
I haven't tried since the 15th July. We pivoted away from using Cypress when we encountered the error
this problem exists if you make a copy of the pencil style and try to use it. copies of minimo seem to work fine.
this problem exists if you make a copy of the pencil style and try to use it. copies of minimo seem to work fine.
@worc this is caused by a new feature in 1.4 which wasn't registered properly. we're working on a 1.4.1 patch which will include a fix for this issue. unfortunately, the broader ticket here isn't related and won't be fixed by 1.4.1
This will be fixed by https://github.com/mapbox/mapbox-gl-js/pull/8868
This will be fixed by #8868
Are users recommended to wait for mapbox-gl 1.6.0 to come out to fix this?
@Tehsurfer No, it will be part of the upcoming 1.5.0 release later this week or early next week.
You can check out 1.5.0-beta.1 meanwhile