mmomtchev / node-gdal-async

Node.js bindings for GDAL (Geospatial Data Abstraction Library) with full async support
https://mmomtchev.github.io/node-gdal-async/
Apache License 2.0
133 stars 26 forks source link

TypeError: gdal.config.set is not a function when tests are run #36

Closed SandeshKR closed 1 year ago

SandeshKR commented 2 years ago

Here's the error I am getting while running tests in nest js. TypeError: gdal.config.set is not a function

Command used: npm run test

I see issues when I run the all the tests. I can run the test with one spec.ts file without any issues.

mmomtchev commented 2 years ago

What are you doing with nest? The tests require a dev install. Can you post the complete series of steps that fail?

SandeshKR commented 2 years ago

I did npm install gdal-async

Made my code change to convert gml to geojson which worked well.

I am able to build code successfully.

But when I run 'npm run test' which runs all the test suites, I get the error.

After your suggestion, I did a dev install by running 'npm run --save -dev gdal-async'

I am getting the same error again.

mmomtchev commented 2 years ago

Running the unit tests requires a git checkout and then running npm install inside node-gdal-async - this is a dev install.

SandeshKR commented 2 years ago

Sorry for not making myself clear.

I have a nestjs project in which I am using gdal-async.

My nestjs project has tests(spec.ts files) which are no way related to anything in gdal-async.

When I run tests in my project, I get the error.

I am using jest for my tests.

Below is the descriptive sample command: npm run cross-env NODE_ENV=XXXX NODE_CONFIG_DIR=XXXX jest --maxWorkers=4

Note: XXXX is replaced by proper values

Does this need a dev install for gdal-async ?

mmomtchev commented 2 years ago

Yes, indeed, I misunderstood you. Can you post the full error output?

SandeshKR commented 2 years ago
Error

Here's the error.

This happens for many spec files when I run all test suites.

The spec.ts file which generates the error does not refer to anything related to gdal-async.

mmomtchev commented 2 years ago

This will be very difficult to reproduce for me. Can you add console.log(gdal, gdal.config) to gdal.js just before the problematic line? You aren't using worker threads - or Nest.js queues? gdal-async is not context aware and can be loaded only once.

SandeshKR commented 2 years ago

Below is the log I got.

I think problematic line is executed more than once when I run all the tests.

To narrow down the scenarios, I tested with two spec.ts files.

The below log is got before the concerned line is executed the first time.

{ open: [Function: open], openAsync: [Function: openAsync], decToDMS: [Function: decToDMS], setPROJSearchPath: [Function: setPROJSearchPath], _triggerCPLError: [Function: _triggerCPLError], _isAlive: [Function: _isAlive], reprojectImage: [Function: reprojectImage], reprojectImageAsync: [Function: reprojectImageAsync], suggestedWarpOutput: [Function: suggestedWarpOutput], suggestedWarpOutputAsync: [Function: suggestedWarpOutputAsync], fillNodata: [Function: fillNodata], fillNodataAsync: [Function: fillNodataAsync], contourGenerate: [Function: contourGenerate], contourGenerateAsync: [Function: contourGenerateAsync], sieveFilter: [Function: sieveFilter], sieveFilterAsync: [Function: sieveFilterAsync], checksumImage: [Function: checksumImage], checksumImageAsync: [Function: checksumImageAsync], polygonize: [Function: polygonize], polygonizeAsync: [Function: polygonizeAsync], addPixelFunc: [Function: addPixelFunc], toPixelFunc: [Function: toPixelFunc], _acquireLocks: [Function: _acquireLocks], _acquireLocksAsync: [Function: _acquireLocksAsync], Driver: [Function: Driver], Dataset: [Function: Dataset], RasterBand: [Function: RasterBand], Group: [Function: Group], MDArray: [Function: MDArray], Dimension: [Function: Dimension], Attribute: [Function: Attribute], Layer: [Function: Layer], Feature: [Function: Feature], FeatureDefn: [Function: FeatureDefn], FieldDefn: [Function: FieldDefn], Geometry: [Function: Geometry] { fromWKT: [Function: fromWKT], fromWKTAsync: [Function: fromWKTAsync], fromWKB: [Function: fromWKB], fromWKBAsync: [Function: fromWKBAsync], fromGeoJson: [Function: fromGeoJson], fromGeoJsonAsync: [Function: fromGeoJsonAsync], fromGeoJsonBuffer: [Function: fromGeoJsonBuffer], fromGeoJsonBufferAsync: [Function: fromGeoJsonBufferAsync], getName: [Function: getName], getConstructor: [Function: getConstructor] }, Point: [Function: Point] { Multi: [Function: MultiPoint] }, SimpleCurve: [Function: SimpleCurve], LineString: [Function: LineString] { Multi: [Function: MultiLineString] }, LinearRing: [Function: LinearRing] { Multi: [Function: MultiLineString] }, Polygon: [Function: Polygon] { Multi: [Function: MultiPolygon] }, GeometryCollection: [Function: GeometryCollection], MultiPoint: [Function: MultiPoint], MultiLineString: [Function: MultiLineString], MultiPolygon: [Function: MultiPolygon], CircularString: [Function: CircularString], CompoundCurve: [Function: CompoundCurve], MultiCurve: [Function: MultiCurve], SpatialReference: [Function: SpatialReference] { fromUserInput: [Function: fromUserInput], fromUserInputAsync: [Function: fromUserInputAsync], fromWKT: [Function: fromWKT], fromProj4: [Function: fromProj4], fromEPSG: [Function: fromEPSG], fromEPSGA: [Function: fromEPSGA], fromESRI: [Function: fromESRI], fromWMSAUTO: [Function: fromWMSAUTO], fromXML: [Function: fromXML], fromURN: [Function: fromURN], fromCRSURL: [Function: fromCRSURL], fromCRSURLAsync: [Function: fromCRSURLAsync], fromURL: [Function: fromURL], fromURLAsync: [Function: fromURLAsync], fromMICoordSys: [Function: fromMICoordSys] }, CoordinateTransformation: [Function: CoordinateTransformation], ColorTable: [Function: ColorTable], DatasetBands: [Function: DatasetBands], DatasetLayers: [Function: DatasetLayers], GroupGroups: [Function: GroupGroups], GroupArrays: [Function: GroupArrays], GroupDimensions: [Function: GroupDimensions], GroupAttributes: [Function: GroupAttributes], ArrayDimensions: [Function: ArrayDimensions], ArrayAttributes: [Function: ArrayAttributes], LayerFeatures: [Function: LayerFeatures], FeatureFields: [Function: FeatureFields], LayerFields: [Function: LayerFields], FeatureDefnFields: [Function: FeatureDefnFields], GeometryCollectionChildren: [Function: GeometryCollectionChildren], PolygonRings: [Function: PolygonRings], LineStringPoints: [Function: LineStringPoints], CompoundCurveCurves: [Function: CompoundCurveCurves], RasterBandOverviews: [Function: RasterBandOverviews], RasterBandPixels: [Function: RasterBandPixels], vsimem: { _anonymous: [Function: _anonymous], set: [Function: set], release: [Function: release], copy: [Function: copy] }, info: [Function: info], infoAsync: [Function: infoAsync], translate: [Function: translate], translateAsync: [Function: translateAsync], vectorTranslate: [Function: vectorTranslate], vectorTranslateAsync: [Function: vectorTranslateAsync], warp: [Function: warp], warpAsync: [Function: warpAsync], buildVRT: [Function: buildVRT], buildVRTAsync: [Function: buildVRTAsync], rasterize: [Function: rasterize], rasterizeAsync: [Function: rasterizeAsync], fs: { stat: [Function: stat], statAsync: [Function: statAsync], readDir: [Function: readDir], readDirAsync: [Function: readDirAsync] }, GDALDrivers: [Function: GDALDrivers], drivers: GDALDrivers {}, DMD_LONGNAME: 'DMD_LONGNAME', DMD_MIMETYPE: 'DMD_MIMETYPE', DMD_HELPTOPIC: 'DMD_HELPTOPIC', DMD_EXTENSION: 'DMD_EXTENSION', DMD_CREATIONOPTIONLIST: 'DMD_CREATIONOPTIONLIST', DMD_CREATIONDATATYPES: 'DMD_CREATIONDATATYPES', CE_None: 0, CE_Debug: 1, CE_Warning: 2, CE_Failure: 3, CE_Fatal: 4, CPLE_None: 0, CPLE_AppDefined: 1, CPLE_OutOfMemory: 2, CPLE_FileIO: 3, CPLE_OpenFailed: 4, CPLE_IllegalArg: 5, CPLE_NotSupported: 6, CPLE_AssertionFailed: 7, CPLE_NoWriteAccess: 8, CPLE_UserInterrupt: 9, CPLE_ObjectNull: 10, DCAP_CREATE: 'DCAP_CREATE', DCAP_CREATECOPY: 'DCAP_CREATECOPY', DCAP_VIRTUALIO: 'DCAP_VIRTUALIO', OLCRandomRead: 'RandomRead', OLCSequentialWrite: 'SequentialWrite', OLCRandomWrite: 'RandomWrite', OLCFastSpatialFilter: 'FastSpatialFilter', OLCFastFeatureCount: 'FastFeatureCount', OLCFastGetExtent: 'FastGetExtent', OLCCreateField: 'CreateField', OLCDeleteField: 'DeleteField', OLCReorderFields: 'ReorderFields', OLCAlterFieldDefn: 'AlterFieldDefn', OLCTransactions: 'Transactions', OLCDeleteFeature: 'DeleteFeature', OLCFastSetNextByIndex: 'FastSetNextByIndex', OLCStringsAsUTF8: 'StringsAsUTF8', OLCIgnoreFields: 'IgnoreFields', OLCCreateGeomField: 'CreateGeomField', ODsCCreateLayer: 'CreateLayer', ODsCDeleteLayer: 'DeleteLayer', ODsCCreateGeomFieldAfterCreateLayer: 'CreateGeomFieldAfterCreateLayer', ODrCCreateDataSource: 'CreateDataSource', ODrCDeleteDataSource: 'DeleteDataSource', GA_ReadOnly: 0, GA_Update: 1, GF_Read: 0, GF_Write: 1, GDT_Unknown: undefined, GDT_Byte: 'Byte', GDT_UInt16: 'UInt16', GDT_Int16: 'Int16', GDT_UInt32: 'UInt32', GDT_Int32: 'Int32', GDT_Float32: 'Float32', GDT_Float64: 'Float64', GDT_CInt16: 'CInt16', GDT_CInt32: 'CInt32', GDT_CFloat32: 'CFloat32', GDT_CFloat64: 'CFloat64', GEDTC_String: 'String', GEDTC_Compound: 'Compound', OJUndefined: undefined, OJLeft: 'Left', OJRight: 'Right', GCI_Undefined: undefined, GCI_GrayIndex: 'Gray', GCI_PaletteIndex: 'Palette', GCI_RedBand: 'Red', GCI_GreenBand: 'Green', GCI_BlueBand: 'Blue', GCI_AlphaBand: 'Alpha', GCI_HueBand: 'Hue', GCI_SaturationBand: 'Saturation', GCI_LightnessBand: 'Lightness', GCI_CyanBand: 'Cyan', GCI_MagentaBand: 'Magenta', GCI_YellowBand: 'Yellow', GCI_BlackBand: 'Black', GCI_YCbCr_YBand: 'YCbCr_Y', GCI_YCbCr_CbBand: 'YCbCr_Cb', GCI_YCbCr_CrBand: 'YCbCr_Cr', GPI_Gray: 'Gray', GPI_RGB: 'RGB', GPI_CMYK: 'CMYK', GPI_HLS: 'HLS', wkbVariantOgc: 'OGC', wkbVariantOldOgc: 'OGC', wkbVariantIso: 'ISO', wkbXDR: 'MSB', wkbNDR: 'LSB', wkb25DBit: 2147483648, wkbUnknown: 0, wkbPoint: 1, wkbLineString: 2, wkbCircularString: 8, wkbCompoundCurve: 9, wkbMultiCurve: 11, wkbPolygon: 3, wkbMultiPoint: 4, wkbMultiLineString: 5, wkbMultiPolygon: 6, wkbGeometryCollection: 7, wkbNone: 100, wkbLinearRing: 101, wkbPoint25D: 2147483649, wkbLineString25D: 2147483650, wkbPolygon25D: 2147483651, wkbMultiPoint25D: 2147483652, wkbMultiLineString25D: 2147483653, wkbMultiPolygon25D: 2147483654, wkbGeometryCollection25D: 2147483655, wkbLinearRing25D: -2147483547, OFTInteger: 'integer', OFTIntegerList: 'integer[]', OFTInteger64: 'integer64', OFTInteger64List: 'integer64[]', OFTReal: 'real', OFTRealList: 'real[]', OFTString: 'string', OFTStringList: 'string[]', OFTWideString: 'wideString', OFTWideStringList: 'wideString[]', OFTBinary: 'binary', OFTDate: 'date', OFTTime: 'time', OFTDateTime: 'dateTime', GRA_NearestNeighbor: 'NearestNeighbor', GRA_Bilinear: 'Bilinear', GRA_Cubic: 'Cubic', GRA_CubicSpline: 'CubicSpline', GRA_Lanczos: 'Lanczos', GRA_Average: 'Average', GRA_Mode: 'Mode', DIM_HORIZONTAL_X: 'HORIZONTAL_X', DIM_HORIZONTAL_Y: 'HORIZONTAL_Y', DIM_VERTICAL: 'VERTICAL', DIM_TEMPORAL: 'TEMPORAL', DIM_PARAMETRIC: 'PARAMETRIC', DIR_EAST: 'EAST', DIR_WEST: 'WEST', DIR_SOUTH: 'SOUTH', DIR_NORTH: 'NORTH', DIR_UP: 'UP', DIR_DOWN: 'DOWN', DIR_FUTURE: 'FUTURE', DIR_PAST: 'PAST', version: '3.5.0', bundled: true, lastError: null, eventLoopWarning: true, quiet: [Function: quiet], verbose: [Function: verbose], startLogging: [Function: startLogging], stopLogging: [Function: stopLogging], log: [Function: log], supports: {}, config: { get: [Function: getConfigOption], set: [Function: setConfigOption] } } { get: [Function: getConfigOption], set: [Function: setConfigOption] }

The below log is got before the concerned line is executed the second time.

{ open: [Function (anonymous)], openAsync: [Function (anonymous)], decToDMS: [Function: decToDMS], setPROJSearchPath: [Function: setPROJSearchPath], _triggerCPLError: [Function: _triggerCPLError], _isAlive: [Function: _isAlive], reprojectImage: [Function: reprojectImage], reprojectImageAsync: [Function (anonymous)], suggestedWarpOutput: [Function: suggestedWarpOutput], suggestedWarpOutputAsync: [Function (anonymous)], fillNodata: [Function: fillNodata], fillNodataAsync: [Function (anonymous)], contourGenerate: [Function: contourGenerate], contourGenerateAsync: [Function (anonymous)], sieveFilter: [Function: sieveFilter], sieveFilterAsync: [Function (anonymous)], checksumImage: [Function: checksumImage], checksumImageAsync: [Function (anonymous)], polygonize: [Function: polygonize], polygonizeAsync: [Function (anonymous)], addPixelFunc: [Function: addPixelFunc], toPixelFunc: [Function: toPixelFunc], _acquireLocks: [Function: _acquireLocks], _acquireLocksAsync: [Function (anonymous)], Driver: [Function: Driver], Dataset: [Function: Dataset], RasterBand: [Function: RasterBand], Group: [Function: Group], MDArray: [Function: MDArray], Dimension: [Function: Dimension], Attribute: [Function: Attribute], Layer: [Function: Layer], Feature: [Function: Feature], FeatureDefn: [Function: FeatureDefn], FieldDefn: [Function: FieldDefn], Geometry: [Function: Geometry] { fromWKT: [Function: fromWKT], fromWKTAsync: [Function (anonymous)], fromWKB: [Function: fromWKB], fromWKBAsync: [Function (anonymous)], fromGeoJson: [Function: fromGeoJson], fromGeoJsonAsync: [Function (anonymous)], fromGeoJsonBuffer: [Function: fromGeoJsonBuffer], fromGeoJsonBufferAsync: [Function (anonymous)], getName: [Function: getName], getConstructor: [Function: getConstructor] }, Point: [Function: Point] { Multi: [Function: MultiPoint] { wkbType: 4 }, wkbType: 1 }, SimpleCurve: [Function: SimpleCurve], LineString: [Function: LineString] { Multi: [Function: MultiLineString] { wkbType: 5 }, wkbType: 2 }, LinearRing: [Function: LinearRing] { Multi: [Function: MultiLineString] { wkbType: 5 }, wkbType: 101 }, Polygon: [Function: Polygon] { Multi: [Function: MultiPolygon] { wkbType: 6 }, wkbType: 3 }, GeometryCollection: [Function: GeometryCollection] { wkbType: 7 }, MultiPoint: [Function: MultiPoint] { wkbType: 4 }, MultiLineString: [Function: MultiLineString] { wkbType: 5 }, MultiPolygon: [Function: MultiPolygon] { wkbType: 6 }, CircularString: [Function: CircularString] { wkbType: 8 }, CompoundCurve: [Function: CompoundCurve] { wkbType: 9 }, MultiCurve: [Function: MultiCurve] { wkbType: 11 }, SpatialReference: [Function: SpatialReference] { fromUserInput: [Function: fromUserInput], fromUserInputAsync: [Function (anonymous)], fromWKT: [Function: fromWKT], fromProj4: [Function: fromProj4], fromEPSG: [Function: fromEPSG], fromEPSGA: [Function: fromEPSGA], fromESRI: [Function: fromESRI], fromWMSAUTO: [Function: fromWMSAUTO], fromXML: [Function: fromXML], fromURN: [Function: fromURN], fromCRSURL: [Function: fromCRSURL], fromCRSURLAsync: [Function (anonymous)], fromURL: [Function: fromURL], fromURLAsync: [Function (anonymous)], fromMICoordSys: [Function: fromMICoordSys] }, CoordinateTransformation: [Function: CoordinateTransformation], ColorTable: [Function: ColorTable], DatasetBands: [Function: DatasetBands], DatasetLayers: [Function: DatasetLayers], GroupGroups: [Function: GroupGroups], GroupArrays: [Function: GroupArrays], GroupDimensions: [Function: GroupDimensions], GroupAttributes: [Function: GroupAttributes], ArrayDimensions: [Function: ArrayDimensions], ArrayAttributes: [Function: ArrayAttributes], LayerFeatures: [Function: LayerFeatures], FeatureFields: [Function: FeatureFields], LayerFields: [Function: LayerFields], FeatureDefnFields: [Function: FeatureDefnFields], GeometryCollectionChildren: [Function: GeometryCollectionChildren], PolygonRings: [Function: PolygonRings], LineStringPoints: [Function: LineStringPoints], CompoundCurveCurves: [Function: CompoundCurveCurves], RasterBandOverviews: [Function: RasterBandOverviews], RasterBandPixels: [Function: RasterBandPixels], vsimem: { _anonymous: [Function: _anonymous], set: [Function: set], release: [Function: release], copy: [Function: copy] }, info: [Function: info], infoAsync: [Function (anonymous)], translate: [Function: translate], translateAsync: [Function (anonymous)], vectorTranslate: [Function: vectorTranslate], vectorTranslateAsync: [Function (anonymous)], warp: [Function: warp], warpAsync: [Function (anonymous)], buildVRT: [Function: buildVRT], buildVRTAsync: [Function (anonymous)], rasterize: [Function: rasterize], rasterizeAsync: [Function (anonymous)], fs: { stat: [Function: stat], statAsync: [Function (anonymous)], readDir: [Function: readDir], readDirAsync: [Function (anonymous)] }, GDALDrivers: [Function: GDALDrivers], drivers: GDALDrivers {}, DMD_LONGNAME: 'DMD_LONGNAME', DMD_MIMETYPE: 'DMD_MIMETYPE', DMD_HELPTOPIC: 'DMD_HELPTOPIC', DMD_EXTENSION: 'DMD_EXTENSION', DMD_CREATIONOPTIONLIST: 'DMD_CREATIONOPTIONLIST', DMD_CREATIONDATATYPES: 'DMD_CREATIONDATATYPES', CE_None: 0, CE_Debug: 1, CE_Warning: 2, CE_Failure: 3, CE_Fatal: 4, CPLE_None: 0, CPLE_AppDefined: 1, CPLE_OutOfMemory: 2, CPLE_FileIO: 3, CPLE_OpenFailed: 4, CPLE_IllegalArg: 5, CPLE_NotSupported: 6, CPLE_AssertionFailed: 7, CPLE_NoWriteAccess: 8, CPLE_UserInterrupt: 9, CPLE_ObjectNull: 10, DCAP_CREATE: 'DCAP_CREATE', DCAP_CREATECOPY: 'DCAP_CREATECOPY', DCAP_VIRTUALIO: 'DCAP_VIRTUALIO', OLCRandomRead: 'RandomRead', OLCSequentialWrite: 'SequentialWrite', OLCRandomWrite: 'RandomWrite', OLCFastSpatialFilter: 'FastSpatialFilter', OLCFastFeatureCount: 'FastFeatureCount', OLCFastGetExtent: 'FastGetExtent', OLCCreateField: 'CreateField', OLCDeleteField: 'DeleteField', OLCReorderFields: 'ReorderFields', OLCAlterFieldDefn: 'AlterFieldDefn', OLCTransactions: 'Transactions', OLCDeleteFeature: 'DeleteFeature', OLCFastSetNextByIndex: 'FastSetNextByIndex', OLCStringsAsUTF8: 'StringsAsUTF8', OLCIgnoreFields: 'IgnoreFields', OLCCreateGeomField: 'CreateGeomField', ODsCCreateLayer: 'CreateLayer', ODsCDeleteLayer: 'DeleteLayer', ODsCCreateGeomFieldAfterCreateLayer: 'CreateGeomFieldAfterCreateLayer', ODrCCreateDataSource: 'CreateDataSource', ODrCDeleteDataSource: 'DeleteDataSource', GA_ReadOnly: 0, GA_Update: 1, GF_Read: 0, GF_Write: 1, GDT_Unknown: undefined, GDT_Byte: 'Byte', GDT_UInt16: 'UInt16', GDT_Int16: 'Int16', GDT_UInt32: 'UInt32', GDT_Int32: 'Int32', GDT_Float32: 'Float32', GDT_Float64: 'Float64', GDT_CInt16: 'CInt16', GDT_CInt32: 'CInt32', GDT_CFloat32: 'CFloat32', GDT_CFloat64: 'CFloat64', GEDTC_String: 'String', GEDTC_Compound: 'Compound', OJUndefined: undefined, OJLeft: 'Left', OJRight: 'Right', GCI_Undefined: undefined, GCI_GrayIndex: 'Gray', GCI_PaletteIndex: 'Palette', GCI_RedBand: 'Red', GCI_GreenBand: 'Green', GCI_BlueBand: 'Blue', GCI_AlphaBand: 'Alpha', GCI_HueBand: 'Hue', GCI_SaturationBand: 'Saturation', GCI_LightnessBand: 'Lightness', GCI_CyanBand: 'Cyan', GCI_MagentaBand: 'Magenta', GCI_YellowBand: 'Yellow', GCI_BlackBand: 'Black', GCI_YCbCr_YBand: 'YCbCr_Y', GCI_YCbCr_CbBand: 'YCbCr_Cb', GCI_YCbCr_CrBand: 'YCbCr_Cr', GPI_Gray: 'Gray', GPI_RGB: 'RGB', GPI_CMYK: 'CMYK', GPI_HLS: 'HLS', wkbVariantOgc: 'OGC', wkbVariantOldOgc: 'OGC', wkbVariantIso: 'ISO', wkbXDR: 'MSB', wkbNDR: 'LSB', wkb25DBit: 2147483648, wkbUnknown: 0, wkbPoint: 1, wkbLineString: 2, wkbCircularString: 8, wkbCompoundCurve: 9, wkbMultiCurve: 11, wkbPolygon: 3, wkbMultiPoint: 4, wkbMultiLineString: 5, wkbMultiPolygon: 6, wkbGeometryCollection: 7, wkbNone: 100, wkbLinearRing: 101, wkbPoint25D: 2147483649, wkbLineString25D: 2147483650, wkbPolygon25D: 2147483651, wkbMultiPoint25D: 2147483652, wkbMultiLineString25D: 2147483653, wkbMultiPolygon25D: 2147483654, wkbGeometryCollection25D: 2147483655, wkbLinearRing25D: -2147483547, OFTInteger: 'integer', OFTIntegerList: 'integer[]', OFTInteger64: 'integer64', OFTInteger64List: 'integer64[]', OFTReal: 'real', OFTRealList: 'real[]', OFTString: 'string', OFTStringList: 'string[]', OFTWideString: 'wideString', OFTWideStringList: 'wideString[]', OFTBinary: 'binary', OFTDate: 'date', OFTTime: 'time', OFTDateTime: 'dateTime', GRA_NearestNeighbor: 'NearestNeighbor', GRA_Bilinear: 'Bilinear', GRA_Cubic: 'Cubic', GRA_CubicSpline: 'CubicSpline', GRA_Lanczos: 'Lanczos', GRA_Average: 'Average', GRA_Mode: 'Mode', DIM_HORIZONTAL_X: 'HORIZONTAL_X', DIM_HORIZONTAL_Y: 'HORIZONTAL_Y', DIM_VERTICAL: 'VERTICAL', DIM_TEMPORAL: 'TEMPORAL', DIM_PARAMETRIC: 'PARAMETRIC', DIR_EAST: 'EAST', DIR_WEST: 'WEST', DIR_SOUTH: 'SOUTH', DIR_NORTH: 'NORTH', DIR_UP: 'UP', DIR_DOWN: 'DOWN', DIR_FUTURE: 'FUTURE', DIR_PAST: 'PAST', version: '3.5.0', bundled: true, lastError: null, eventLoopWarning: true, quiet: [Function: quiet], verbose: [Function: verbose], startLogging: [Function: startLogging], stopLogging: [Function: stopLogging], log: [Function: log], supports: {}, config: { get: undefined, set: undefined }, Envelope: [Function: Envelope], Envelope3D: [Function: Envelope3D], RasterReadStream: [class RasterReadStream extends Readable], RasterWriteStream: [class RasterWriteStream extends Writable], RasterMuxStream: [class RasterMuxStream extends Readable], RasterTransform: [class RasterTransform extends Transform], calcAsync: [Function: calcAsync], wrapVRT: [Function: wrapVRT], createPixelFunc: [Function: createPixelFunc], createPixelFuncWithArgs: [Function: createPixelFunc], fromDataType: [Function (anonymous)], toDataType: [Function (anonymous)] } { get: undefined, set: undefined }

I am trying to recreate the issue in a sample project. Will be attaching that here in sometime

SandeshKR commented 2 years ago

my-nest-project.zip

Here's a sample project with a repro.

When I created a Testing module in spec.ts files, I was able to repro the error.

Below are the commands to run to repro the issue. npm install npm run test

Let me know if you need more info

mmomtchev commented 2 years ago

npm run test works for me on Node.js 16.15.1 on Linux, what platform are you using?

SandeshKR commented 2 years ago

I am using node 14.15.0 on Mac os Monterey (12.1)

SandeshKR commented 2 years ago

I did upgrade to node 16.15.1 on my mac. I was able to run the tests first time without issues in the sample project. When I ran the tests again, the tests started failing with the error.

Can you please try running the tests using npm run test atleast 5 times to repro the error ?

After following the above steps, if you are still unable to repro Delete 'node_modules' and 'package-lock.json'. run npm install run npm run test atleast 5 times.

You should be able to repro the error

SandeshKR commented 2 years ago

@mmomtchev Are you able to repro the error ?

mmomtchev commented 2 years ago

I did run your test in an infinite loop with both Node 14.15 and Node 16.15 on macOS Big Sur without reproducing the error

AlexandreMichelix commented 1 year ago

Untitled

AlexandreMichelix commented 1 year ago

gdal, gdal.config { open: [Function (anonymous)], openAsync: [Function (anonymous)], decToDMS: [Function: decToDMS], setPROJSearchPath: [Function: setPROJSearchPath], _triggerCPLError: [Function: _triggerCPLError], _isAlive: [Function: _isAlive], reprojectImage: [Function: reprojectImage], reprojectImageAsync: [Function (anonymous)], suggestedWarpOutput: [Function: suggestedWarpOutput], suggestedWarpOutputAsync: [Function (anonymous)], fillNodata: [Function: fillNodata], fillNodataAsync: [Function (anonymous)], contourGenerate: [Function: contourGenerate], contourGenerateAsync: [Function (anonymous)], sieveFilter: [Function: sieveFilter], sieveFilterAsync: [Function (anonymous)], checksumImage: [Function: checksumImage], checksumImageAsync: [Function (anonymous)], polygonize: [Function: polygonize], polygonizeAsync: [Function (anonymous)], addPixelFunc: [Function: addPixelFunc], toPixelFunc: [Function: toPixelFunc], _acquireLocks: [Function: _acquireLocks], _acquireLocksAsync: [Function (anonymous)], Driver: [Function: Driver], Dataset: [Function: Dataset], RasterBand: [Function: RasterBand], Group: [Function: Group], MDArray: [Function: MDArray], Dimension: [Function: Dimension], Attribute: [Function: Attribute], Layer: [Function: Layer], Feature: [Function: Feature], FeatureDefn: [Function: FeatureDefn], FieldDefn: [Function: FieldDefn], Geometry: [Function: Geometry] { fromWKT: [Function: fromWKT], fromWKTAsync: [Function (anonymous)], fromWKB: [Function: fromWKB], fromWKBAsync: [Function (anonymous)], fromGeoJson: [Function: fromGeoJson], fromGeoJsonAsync: [Function (anonymous)], fromGeoJsonBuffer: [Function: fromGeoJsonBuffer], fromGeoJsonBufferAsync: [Function (anonymous)], getName: [Function: getName], getConstructor: [Function: getConstructor] }, Point: [Function: Point] { Multi: [Function: MultiPoint] { wkbType: 4 }, wkbType: 1 }, SimpleCurve: [Function: SimpleCurve], LineString: [Function: LineString] { Multi: [Function: MultiLineString] { wkbType: 5 }, wkbType: 2 }, LinearRing: [Function: LinearRing] { Multi: [Function: MultiLineString] { wkbType: 5 }, wkbType: 101 }, Polygon: [Function: Polygon] { Multi: [Function: MultiPolygon] { wkbType: 6 }, wkbType: 3 }, GeometryCollection: [Function: GeometryCollection] { wkbType: 7 }, MultiPoint: [Function: MultiPoint] { wkbType: 4 }, MultiLineString: [Function: MultiLineString] { wkbType: 5 }, MultiPolygon: [Function: MultiPolygon] { wkbType: 6 }, CircularString: [Function: CircularString] { wkbType: 8 }, CompoundCurve: [Function: CompoundCurve] { wkbType: 9 }, MultiCurve: [Function: MultiCurve] { wkbType: 11 }, SpatialReference: [Function: SpatialReference] { fromUserInput: [Function: fromUserInput], fromUserInputAsync: [Function (anonymous)], fromWKT: [Function: fromWKT], fromProj4: [Function: fromProj4], fromEPSG: [Function: fromEPSG], fromEPSGA: [Function: fromEPSGA], fromESRI: [Function: fromESRI], fromWMSAUTO: [Function: fromWMSAUTO], fromXML: [Function: fromXML], fromURN: [Function: fromURN], fromCRSURL: [Function: fromCRSURL], fromCRSURLAsync: [Function (anonymous)], fromURL: [Function: fromURL], fromURLAsync: [Function (anonymous)], fromMICoordSys: [Function: fromMICoordSys] }, CoordinateTransformation: [Function: CoordinateTransformation], ColorTable: [Function: ColorTable], DatasetBands: [Function: DatasetBands], DatasetLayers: [Function: DatasetLayers], GroupGroups: [Function: GroupGroups], GroupArrays: [Function: GroupArrays], GroupDimensions: [Function: GroupDimensions], GroupAttributes: [Function: GroupAttributes], ArrayDimensions: [Function: ArrayDimensions], ArrayAttributes: [Function: ArrayAttributes], LayerFeatures: [Function: LayerFeatures], FeatureFields: [Function: FeatureFields], LayerFields: [Function: LayerFields], FeatureDefnFields: [Function: FeatureDefnFields], GeometryCollectionChildren: [Function: GeometryCollectionChildren], PolygonRings: [Function: PolygonRings], LineStringPoints: [Function: LineStringPoints], CompoundCurveCurves: [Function: CompoundCurveCurves], RasterBandOverviews: [Function: RasterBandOverviews], RasterBandPixels: [Function: RasterBandPixels], vsimem: { _anonymous: [Function: _anonymous], set: [Function: set], release: [Function: release], copy: [Function: copy] }, info: [Function: info], infoAsync: [Function (anonymous)], translate: [Function: translate], translateAsync: [Function (anonymous)], vectorTranslate: [Function: vectorTranslate], vectorTranslateAsync: [Function (anonymous)], warp: [Function: warp], warpAsync: [Function (anonymous)], buildVRT: [Function: buildVRT], buildVRTAsync: [Function (anonymous)], rasterize: [Function: rasterize], rasterizeAsync: [Function (anonymous)], dem: [Function: dem], demAsync: [Function (anonymous)], fs: { stat: [Function: stat], statAsync: [Function (anonymous)], readDir: [Function: readDir], readDirAsync: [Function (anonymous)] }, GDALDrivers: [Function: GDALDrivers], drivers: GDALDrivers {}, DMD_LONGNAME: 'DMD_LONGNAME', DMD_MIMETYPE: 'DMD_MIMETYPE', DMD_HELPTOPIC: 'DMD_HELPTOPIC', DMD_EXTENSION: 'DMD_EXTENSION', DMD_CREATIONOPTIONLIST: 'DMD_CREATIONOPTIONLIST', DMD_CREATIONDATATYPES: 'DMD_CREATIONDATATYPES', CE_None: 0, CE_Debug: 1, CE_Warning: 2, CE_Failure: 3, CE_Fatal: 4, CPLE_None: 0, CPLE_AppDefined: 1, CPLE_OutOfMemory: 2, CPLE_FileIO: 3, CPLE_OpenFailed: 4, CPLE_IllegalArg: 5, CPLE_NotSupported: 6, CPLE_AssertionFailed: 7, CPLE_NoWriteAccess: 8, CPLE_UserInterrupt: 9, CPLE_ObjectNull: 10, DCAP_CREATE: 'DCAP_CREATE', DCAP_CREATECOPY: 'DCAP_CREATECOPY', DCAP_VIRTUALIO: 'DCAP_VIRTUALIO', OLCRandomRead: 'RandomRead', OLCSequentialWrite: 'SequentialWrite', OLCRandomWrite: 'RandomWrite', OLCFastSpatialFilter: 'FastSpatialFilter', OLCFastFeatureCount: 'FastFeatureCount', OLCFastGetExtent: 'FastGetExtent', OLCCreateField: 'CreateField', OLCDeleteField: 'DeleteField', OLCReorderFields: 'ReorderFields', OLCAlterFieldDefn: 'AlterFieldDefn', OLCTransactions: 'Transactions', OLCDeleteFeature: 'DeleteFeature', OLCFastSetNextByIndex: 'FastSetNextByIndex', OLCStringsAsUTF8: 'StringsAsUTF8', OLCIgnoreFields: 'IgnoreFields', OLCCreateGeomField: 'CreateGeomField', ODsCCreateLayer: 'CreateLayer', ODsCDeleteLayer: 'DeleteLayer', ODsCCreateGeomFieldAfterCreateLayer: 'CreateGeomFieldAfterCreateLayer', ODrCCreateDataSource: 'CreateDataSource', ODrCDeleteDataSource: 'DeleteDataSource', GA_ReadOnly: 0, GA_Update: 1, GF_Read: 0, GF_Write: 1, GDT_Unknown: undefined, GDT_Byte: 'Byte', GDT_UInt16: 'UInt16', GDT_Int16: 'Int16', GDT_UInt32: 'UInt32', GDT_Int32: 'Int32', GDT_Float32: 'Float32', GDT_Float64: 'Float64', GDT_CInt16: 'CInt16', GDT_CInt32: 'CInt32', GDT_CFloat32: 'CFloat32', GDT_CFloat64: 'CFloat64', GEDTC_String: 'String', GEDTC_Compound: 'Compound', OJUndefined: undefined, OJLeft: 'Left', OJRight: 'Right', GCI_Undefined: undefined, GCI_GrayIndex: 'Gray', GCI_PaletteIndex: 'Palette', GCI_RedBand: 'Red', GCI_GreenBand: 'Green', GCI_BlueBand: 'Blue', GCI_AlphaBand: 'Alpha', GCI_HueBand: 'Hue', GCI_SaturationBand: 'Saturation', GCI_LightnessBand: 'Lightness', GCI_CyanBand: 'Cyan', GCI_MagentaBand: 'Magenta', GCI_YellowBand: 'Yellow', GCI_BlackBand: 'Black', GCI_YCbCr_YBand: 'YCbCr_Y', GCI_YCbCr_CbBand: 'YCbCr_Cb', GCI_YCbCr_CrBand: 'YCbCr_Cr', GPI_Gray: 'Gray', GPI_RGB: 'RGB', GPI_CMYK: 'CMYK', GPI_HLS: 'HLS', wkbVariantOgc: 'OGC', wkbVariantOldOgc: 'OGC', wkbVariantIso: 'ISO', wkbXDR: 'MSB', wkbNDR: 'LSB', wkb25DBit: 2147483648, wkbUnknown: 0, wkbPoint: 1, wkbLineString: 2, wkbCircularString: 8, wkbCompoundCurve: 9, wkbMultiCurve: 11, wkbPolygon: 3, wkbMultiPoint: 4, wkbMultiLineString: 5, wkbMultiPolygon: 6, wkbGeometryCollection: 7, wkbNone: 100, wkbLinearRing: 101, wkbPoint25D: 2147483649, wkbLineString25D: 2147483650, wkbPolygon25D: 2147483651, wkbMultiPoint25D: 2147483652, wkbMultiLineString25D: 2147483653, wkbMultiPolygon25D: 2147483654, wkbGeometryCollection25D: 2147483655, wkbLinearRing25D: -2147483547, OFTInteger: 'integer', OFTIntegerList: 'integer[]', OFTInteger64: 'integer64', OFTInteger64List: 'integer64[]', OFTReal: 'real', OFTRealList: 'real[]', OFTString: 'string', OFTStringList: 'string[]', OFTWideString: 'wideString', OFTWideStringList: 'wideString[]', OFTBinary: 'binary', OFTDate: 'date', OFTTime: 'time', OFTDateTime: 'dateTime', GRA_NearestNeighbor: 'NearestNeighbor', GRA_Bilinear: 'Bilinear', GRA_Cubic: 'Cubic', GRA_CubicSpline: 'CubicSpline', GRA_Lanczos: 'Lanczos', GRA_Average: 'Average', GRA_Mode: 'Mode', DIM_HORIZONTAL_X: 'HORIZONTAL_X', DIM_HORIZONTAL_Y: 'HORIZONTAL_Y', DIM_VERTICAL: 'VERTICAL', DIM_TEMPORAL: 'TEMPORAL', DIM_PARAMETRIC: 'PARAMETRIC', DIR_EAST: 'EAST', DIR_WEST: 'WEST', DIR_SOUTH: 'SOUTH', DIR_NORTH: 'NORTH', DIR_UP: 'UP', DIR_DOWN: 'DOWN', DIR_FUTURE: 'FUTURE', DIR_PAST: 'PAST', version: '3.6.2', bundled: true, lastError: null, eventLoopWarning: true, quiet: [Function: quiet], verbose: [Function: verbose], startLogging: [Function: startLogging], stopLogging: [Function: stopLogging], log: [Function: log], supports: {}, config: { get: [Function: getConfigOption], set: [Function: setConfigOption] }, Envelope: [Function: Envelope], Envelope3D: [Function: Envelope3D], RasterReadStream: [class RasterReadStream extends Readable], RasterWriteStream: [class RasterWriteStream extends Writable], RasterMuxStream: [class RasterMuxStream extends Readable], RasterTransform: [class RasterTransform extends Transform], calcAsync: [Function: calcAsync], wrapVRT: [Function: wrapVRT], createPixelFunc: [Function: createPixelFunc], createPixelFuncWithArgs: [Function: createPixelFunc], fromDataType: [Function (anonymous)], toDataType: [Function (anonymous)] } { get: [Function: getConfigOption], set: [Function: setConfigOption] }

AlexandreMichelix commented 1 year ago

I followed this issue, it works for gdal but not for gdal-async : https://github.com/naturalatlas/node-gdal/issues/207 GDAL_DATA: node_modules/gdal/deps/libgdal/gdal/data

AlexandreMichelix commented 1 year ago

image

AlexandreMichelix commented 1 year ago

I'm using v16.15.1 on Linux

mmomtchev commented 1 year ago

Do you get the error if you run jest -i?

AlexandreMichelix commented 1 year ago

Yes same error, I think my GDAL_DATA is not correct

mmomtchev commented 1 year ago

@AlexandreMichelix, I am quite convinced that the original explanation is the right one, jest manages to load the bindings multiple times in the same thread. Do you have a public repository where this happens?

mmomtchev commented 1 year ago

@AlexandreMichelix Can you test #72, there will be a new release very soon? (the crash was related to Node.js 19.18.0, it is fixed in 19.18.1)

mmomtchev commented 1 year ago

@AlexandreMichelix Are you positive you (or jest) are not spawning worker_threads? worker_threads are not supported and will cause a variety of very weird problems and crashes.

AlexandreMichelix commented 1 year ago

@mmomtchev I tested with this PR #72 and it works perfectly ! Thank you ! With that, I can init Gdal so I have my variable GDAL_DATA in my .gitlab-ci.yml : image and so I can implement into my package : image

image