Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.1k stars 1.21k forks source link

Cannot read property 'find' of undefined #15947

Closed rudesome closed 3 years ago

rudesome commented 3 years ago

Am trying to learn cosmosDB and testing some basic stuff like;

const { CosmosClient } = require("@azure/cosmos");

const endpoint = 'endpoint'
const key = 'sec_key'
const client = new CosmosClient({ endpoint, key });
async function main() {
    // The rest of the README samples are designed to be pasted into this function body
    const { database } = await client.databases.createIfNotExists({ id: "DB_NAME" });
    console.log(database.id);
}

main().catch((error) => {
    console.error(error);
});

straight out of the tutorial. and when i run this with version "@azure/cosmos": "^3.11.5" I get the following error:

TypeError: Cannot read property 'find' of undefined
    at GlobalEndpointManager.<anonymous> (C:\T\node_modules\@azure\cosmos\dist\index.js:8709:53)
    at Generator.next (<anonymous>)
    at fulfilled (C:\T\node_modules\tslib\tslib.js:114:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

but when i run it with version: "@azure/cosmos": "3.5.2" it is working just fine..

am i missing something or need the docs to be updated?

zfoster commented 3 years ago

hey @ParkHost I'll take a look

zfoster commented 3 years ago

hmm @ParkHost with 3.11.5 I'm not receiving the error. It's possible it was an issue with the first request which I think will be fixed in an upcoming release. Can you try that version again?

rudesome commented 3 years ago

still receiving the error, am working on a windows 10 system. Tried both node versions LTS 14 and newest 16.4 Even spinned up a dev win 10 system in hyper-v...

See my repo as example: https://github.com/ParkHost/test_azure_cosmos

zfoster commented 3 years ago

I see - is it possible you have a multi-region write account with no regions? This will be fixed in the next release but I’m unsure what’s causing it yet. The error is because the SDK isn’t finding any read endpoints.

Software Engineer CosmosDB


From: DevNULL @.> Sent: Saturday, June 26, 2021 3:47:36 AM To: Azure/azure-sdk-for-js @.> Cc: Zach Foster @.>; Assign @.> Subject: Re: [Azure/azure-sdk-for-js] Cannot read property 'find' of undefined (#15947)

still receiving the error, am working on a windows 10 system. Tried both node versions LTS 14 and newest 16.4 Even spinned up a dev win 10 system in hyper-v...

See my repo as example: https://github.com/ParkHost/test_azure_cosmoshttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FParkHost%2Ftest_azure_cosmos&data=04%7C01%7CZach.Foster%40microsoft.com%7Cfe7a412284d44f7b8d5d08d93876aa8c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637602904585724047%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4dOtyX3mZ4dfC3oGQ5%2F7tnVb9BsPeA0ga3B%2Fwi4y9YM%3D&reserved=0

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-sdk-for-js%2Fissues%2F15947%23issuecomment-868963895&data=04%7C01%7CZach.Foster%40microsoft.com%7Cfe7a412284d44f7b8d5d08d93876aa8c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637602904585724047%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=KirI%2BkymlUiFJYlvdriZcJ4vpPI1b6THeb%2BkIhJqJNo%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAALHHQSQGOW3O7Y3TXG7TQTTUWAZRANCNFSM47IBLAIQ&data=04%7C01%7CZach.Foster%40microsoft.com%7Cfe7a412284d44f7b8d5d08d93876aa8c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637602904585733999%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=HtDBiWWOikGPaLxOi8J3URrRQOgzIh9j8D9DSiq3tZ4%3D&reserved=0.

rudesome commented 3 years ago

Am using cosmos emulator

zfoster commented 3 years ago

this should be fixed in the next release @ParkHost

zfoster commented 3 years ago

@ParkHost can you try using 3.12.0?

rudesome commented 3 years ago

@zfoster , the error is gone but i dont get anything back in my console.log(database.id) ..? please have a look at my repo, not sure if i do anything wrong, cause it is straight from the tutorial

rudesome commented 3 years ago

solved it with: NODE_TLS_REJECT_UNAUTHORIZED=0 , thanks