turf icon indicating copy to clipboard operation
turf copied to clipboard

Turf v7 in BigQuery: TypeError: base intrinsic for Date.prototype.getTime exists, but the property is not available

Open svbatalov opened this issue 8 months ago • 1 comments

Hello. Thanks for this great library!

I've encountered the following error message when tried to use a browserified version of [email protected] in BigQuery:

TypeError: base intrinsic for Date.prototype.getTime exists, but the property is not available ...

The way I bundled the library

browserify -r @turf/turf -s turf > turf7.js

Then used it in a BQ UDF as follows:

CREATE TEMP FUNCTION tst()
RETURNS STRING
LANGUAGE js
OPTIONS (
    library=["gs://.../turf7.js"]
) AS """
""";

SELECT tst()

As a workaround, I created the entry point JS file and added this line

Date.prototype.getTime = () => {};

before requiring the library.

It looks like this issue is caused by the deep-equal library that references getTime here.

Not sure if there are any action items for this issue -- after all, it probably should be filed against deep-equal, so feel free to close it. Just wanted to log it here for anyone encountering similar issues.

Cheers, Sergey

svbatalov avatar Jun 25 '24 06:06 svbatalov