turf icon indicating copy to clipboard operation
turf copied to clipboard

TypeError: Cannot read property 'POLYGON_CLIPPING_MAX_QUEUE_SIZE' of undefined

Open cloudhx opened this issue 3 years ago • 8 comments

@turf/turf 6.5.0 webpack 5

I'm using turf in a NativeScript project, the sample code could be very simple:

import * as turf from '@turf/turf';

export class TestClass {
  testFn() {
    const p = turf.point([-73.988214, 40.749128]);
  }
}

I tried all turf version above 5.1.6, all get the same error, but when using 5.1.6, it works well.

Thanks for the help!

cloudhx avatar Oct 10 '22 14:10 cloudhx

Hmm it's due to something upstream in the polygon-clipping library but it's been there for ages so I'm not sure why it's a particular problem in your instance that no-one else has reported...

https://github.com/mfogel/polygon-clipping/blob/b064f942061e9820c53a462ebcccda7407330007/src/operation.js#L10-L17

rowanwins avatar Oct 11 '22 00:10 rowanwins

Thanks @rowanwins for your quick feedback. Yeah, I understand that and cannot google much about it either. I can live with version 5.1.8 at the moment and probably will try to reproduce it in a plain empty project to get a bit more info. Thanks again!

cloudhx avatar Oct 11 '22 10:10 cloudhx

If I was going to hazard a guess process isn't available in the NativeScript environment.

rowanwins avatar Oct 12 '22 00:10 rowanwins

I'm using Turf with a Nuxt JS project and just started seeing this as well. It looks like the client side env isn't being defined suddenly (weird).

@cloudhx Which Native Script flavor are you using? Could a check be added for process.env !== 'undefined'?

The same would need to be done for POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS.

evans23 avatar Nov 22 '22 19:11 evans23

Possible workaround here https://github.com/nuxt/nuxt.js/issues/14276

BenWortley avatar Dec 25 '22 13:12 BenWortley

I am able to reproduce this when I run my vue component (which imports bbox from turf) in a cypress component test, but unable to reproduce it when I run that vue component locally. Very odd.

lukkyjoe avatar Jan 18 '23 17:01 lukkyjoe

It seems the error is gone anyway, will verify the version and code with some latest setup.

cloudhx avatar Feb 15 '23 08:02 cloudhx

Any updates?? I have the same problem. @Ben-VP thanks for this workaround!

Edit: I update my Nuxt version and it works fine without any workarounds :)

szulcus avatar Sep 29 '23 11:09 szulcus