Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Cannot read properties of undefined (reading 'country_code') #354

Merged
merged 4 commits into from
Mar 17, 2024

Conversation

nrathi
Copy link
Contributor

@nrathi nrathi commented Feb 27, 2024

Fixes #350.

I would really appreciate if this could be merged in the near future, as it's affecting the uptime of my app.

Usage (the try/catch doesn't help):

  await geocoder
    .geocode(privateListingRes.address)
    .then((entries) => {
      const entry = entries[0];
      if (entry?.latitude && entry.longitude) {
        latitude = entry.latitude;
        longitude = entry.longitude;
      }
    })
    .catch(() => undefined);

Error:

TypeError: Cannot read properties of undefined (reading 'country_code')
    at OpenStreetMapGeocoder._formatResult (/home/ec2-user/superset/node_modules/.pnpm/node-geocoder@4.2.0/node_modules/node-geocoder/lib/geocoder/openstreetmapgeocoder.js:71:38)
    at /home/ec2-user/superset/node_modules/.pnpm/node-geocoder@4.2.0/node_modules/node-geocoder/lib/geocoder/openstreetmapgeocoder.js:58:34
    at tryCatcher (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/util.js:16:23)
    at Promise.successAdapter [as _fulfillmentHandler0] (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/nodeify.js:23:30)
    at Promise._settlePromise (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/promise.js:601:21)
    at Promise._settlePromise0 (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues (/home/ec2-user/superset/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:466:21)

@nchaulet nchaulet self-requested a review February 28, 2024 12:07
@nrathi
Copy link
Contributor Author

nrathi commented Feb 28, 2024

Not sure why the tests were failing but I updated w/ the code I used in my patch.

@nchaulet nchaulet merged commit e225f77 into nchaulet:main Mar 17, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of undefined (reading 'country_code')
2 participants