geoarrow-js icon indicating copy to clipboard operation
geoarrow-js copied to clipboard

Failed to execute 'structuredClone' on prepared vector

Open rajsite opened this issue 2 years ago • 3 comments

Trying to use the preparePostMessage and rehydrateVector helpers on the README example I get the error message:

Uncaught DOMException: Failed to execute 'structuredClone' on 'Window': (index) => isChunkedValid(unchunkedData, index) could not be cloned.

See stackblitz example: https://stackblitz.com/edit/geoarrow-readme-worker-example?file=src%2Fmain.ts&terminal=dev And open devtools to see the error.

npm list:

+-- @esbuild/[email protected] extraneous
+-- @geoarrow/[email protected]
+-- @rollup/[email protected] extraneous
+-- @rollup/[email protected] extraneous
+-- [email protected]
+-- [email protected]
`-- [email protected]

rajsite avatar Feb 21 '24 01:02 rajsite

Looks like the tests only cover Data and not Vector, maybe an issue has been introduced?

It does look like preparePostMessage(Data) and rehydrateData are working but the vector example shown in the README does not seem to.

rajsite avatar Feb 21 '24 04:02 rajsite

I don't think I ever tested it on Vector, despite implementing preparePostMessage on Vector and rehydrateVector.

Presumably the issue is that a few methods are assigned as attributes with function definitions https://github.com/apache/arrow/blob/6a22a1dee78b0f7daa7e4d8793d663e29a5712a6/js/src/vector.ts#L81-L84

kylebarron avatar Feb 21 '24 14:02 kylebarron

I figure that the best solution is to create a new object with only known properties https://github.com/apache/arrow/blob/6a22a1dee78b0f7daa7e4d8793d663e29a5712a6/js/src/vector.ts#L93-L97.

Are you interested in making a PR? It's probably just a couple lines here https://github.com/geoarrow/geoarrow-js/blob/75d35765cb1552be0f5562b35055f0b84ad1fa68/src/worker/transferable.ts#L33

kylebarron avatar Feb 21 '24 15:02 kylebarron