tomayac / local-reverse-geocoder

Local reverse geocoder for Node.js based on GeoNames data
Apache License 2.0
190 stars 58 forks source link

Help - getting error #79

Closed junglebells closed 10 months ago

junglebells commented 1 year ago

Here's the error from docker logs - please advise:

Local reverse geocoder listening on port 3000 Initializing Geocoder… (This may take a long time and will download ~2.29GB worth of data by default.) (node:17) UnhandledPromiseRejectionWarning: Error: Not supported at fetch (/app/index.js:43:24) at Object._downloadAndExtractFileFromZip (/app/index.js:241:5) at Object._getData (/app/index.js:168:5) at Object._getGeoNamesCitiesData (/app/index.js:468:10) at nextTask (/app/node_modules/async/dist/async.js:5789:27) at Object.waterfall (/app/node_modules/async/dist/async.js:5800:9) at Object.awaitable [as waterfall] (/app/node_modules/async/dist/async.js:211:32) at /app/index.js:682:19 at eachfn (/app/node_modules/async/dist/async.js:3674:28) at eachOfArrayLike (/app/node_modules/async/dist/async.js:506:13) (node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:17) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

tomayac commented 1 year ago

I just tried it locally and it ran fine. To be on the safe side, released a new Docker image. Can you see if this works now?

junglebells commented 1 year ago

Thanks for looking into it - I am still getting this error:

$ docker run -it -e PORT=3000 --rm ghcr.io/tomayac/local-reverse-geocoder

local-reverse-geocoder@0.16.5 start /app node --max-old-space-size=4095 app.js

Local reverse geocoder listening on port 3000 Initializing Geocoder… (This may take a long time and will download ~2.29GB worth of data by default.) (node:24) UnhandledPromiseRejectionWarning: Error: Not supported at fetch (/app/index.js:43:24) at Object._downloadAndExtractFileFromZip (/app/index.js:241:5) at Object._getData (/app/index.js:168:5) at Object._getGeoNamesCitiesData (/app/index.js:468:10) at nextTask (/app/node_modules/async/dist/async.js:5789:27) at Object.waterfall (/app/node_modules/async/dist/async.js:5800:9) at Object.awaitable [as waterfall] (/app/node_modules/async/dist/async.js:211:32) at /app/index.js:682:19 at eachfn (/app/node_modules/async/dist/async.js:3674:28) at eachOfArrayLike (/app/node_modules/async/dist/async.js:506:13) (node:24) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:24) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I tried this with fresh install of Debian 12 and Ubuntu Server 22.04 - same error on both. Could there be a package missing?

$ uname -a Linux ubu 5.15.0-82-generic #91-Ubuntu SMP Mon Aug 14 14:14:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

tomayac commented 1 year ago

@yjwong, as the original author of the Docker file, do you have an idea why this error happens in Docker contexts, but not when run locally?

yjwong commented 1 year ago

I suspect it might be the Node.js version that's used in the Dockerfile. Looking at the stack trace, the error happens on the import(), which is part of ES modules.

The Dockerfile uses Node.js v10 - rather old by now, and doesn't have dynamic imports enabled by default. I think this could be solved by using a newer version of Node.js as the base image - something newer than the "engines" declared in package.json.

junglebells commented 1 year ago

I was able to fix this issue on my local machine by making the following changes to Dockerfile:

Line 1 changed to "FROM node:current-alpine" Line 5 changed to "ADD package.json package-lock.json postinstall.js /app/

@tomayac you may need to build the docker image after these changes.

Hope this helps. Thanks for a wonderful program.