azure-cosmos-db-emulator-docker icon indicating copy to clipboard operation
azure-cosmos-db-emulator-docker copied to clipboard

‎Linux-based emulator does not support continuations

Open bruniela opened this issue 10 months ago • 5 comments

Describe the bug I am running integration tests on an application composed by a Cosmos DB database and some function apps. In order to reduce costs in test development I have opted to make the tests point to the Cosmos DB emulator, after I had developed some tests on the real thing. Some of the tests no longer work, as I get this error:

ErrorResponse: Having continuations not supported for this type of query Cosmos query text: SELECT * FROM c WHERE c.kind='R' ORDER BY c.mail DESC -> SELECT * FROM %s AS c WHERE cosmos_catalog.cosmos_eq(c.document, '{"kind":"R"}') ORDER BY (c.document)->'mail' DESC
     at httpRequest (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:11499:31)
     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
     at async /home/<project-path>/node_modules/@azure/cosmos/dist/index.js:11314:30
     at async addDignosticChild (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:2304:26)
     at async addDignosticChild (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:2304:26)
     at async ClientContext.queryFeed (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:11973:26)
     at async Array.fetchFunction (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:8726:30)
     at async addDignosticChild.queryMethodIdentifier (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:4775:34)
     at async addDignosticChild (/home/<project-path>/node_modules/@azure/cosmos/dist/index.js:2304:26)
     at async /home/<project-path>/node_modules/@azure/cosmos/dist/index.js:7417:28 {
   code: 500,
   body: {
     code: 'InternalServerError',
     message: `Having continuations not supported for this type of query Cosmos query text: SELECT * FROM c WHERE c.kind='R' ORDER BY c.mail DESC -> SELECT * FROM %s AS c WHERE cosmos_catalog.cosmos_eq(c.document, '{"kind":"R"}') ORDER BY (c.document)->'mail' DESC`
   },
   headers: {
     date: 'Fri, 17 Jan 2025 17:38:05 GMT',
     'transfer-encoding': 'chunked',
     'content-type': 'application/json',
     server: 'PGSQL',
     'x-ms-gatewayversion': '2.0.0',
     'x-ms-activity-id': '9766bde9-5d5a-4598-b4f7-0ba9d0bdf49a',
     'x-ms-documentdb-partitionkeyrangeid': '0',
     'x-ms-session-token': '0:-1#1',
     'x-ms-interopandsdk-time-ms': '2',
     'x-ms-cosmos-correlated-activityid': 'c21c89f1-d580-4059-97c2-1319b087f221',
     'x-ms-throttle-retry-count': 0,
     'x-ms-throttle-retry-wait-time-ms': 0
   },
   activityId: '9766bde9-5d5a-4598-b4f7-0ba9d0bdf49a',
   diagnostics: CosmosDiagnostics {
     clientSideRequestStatistics: {
       requestStartTimeUTCInMs: 1737135486409,
       requestDurationInMs: 6,
       totalRequestPayloadLengthInBytes: 130,
       totalResponsePayloadLengthInBytes: 773,
       locationEndpointsContacted: [Array],
       metadataDiagnostics: [Object],
       retryDiagnostics: [Object],
       gatewayStatistics: [Array]
     },
     diagnosticNode: undefined,
     clientConfig: undefined
   }
 }

This occurs when querying the containers using the @azure/cosmos library for JavaScript/TypeScript using the approach of executing non-streamable cross-partition queries, as documented in the library documentation:


const querySpec = {
  query: "SELECT c.status, COUNT(c.id) AS count FROM c GROUP BY c.status",
};
const queryOptions = {
  maxItemCount: 10, // maximum number of items to return per page
  enableCrossPartitionQuery: true,
};
const querIterator = await container.items.query(querySpec, queryOptions);
while (querIterator.hasMoreResults()) {
  const { resources: result } = await querIterator.fetchNext();
  //Do something with result
}

Since when pointing to a real Cosmos DB account everything works as expected, I believe the issue might be on the emulator. Every other query to the emulator has produced the intended results, it is just query iterators that fail.

To Reproduce Steps to reproduce the behavior:

  1. Open emulator
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview

docker run --name cosmosdb_docker --detach --publish 8081:8081 --publish 1234:1234 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
  1. Create a container and populate it with several records;

  2. Query the container using a query iterator, with maxItemCount < total amount of records

  3. The query will fail with the error ErrorResponse: Having continuations not supported for this type of query

Expected behavior The query produces the same result on the emulator and on the real thing

Desktop (please complete the following information):

  • OS: KDE neon 6.0
  • SDK: @azure/cosmos: version 4.2.0
  • Language: JavaScript/TypeScript

bruniela avatar Jan 17 '25 18:01 bruniela

I'm facing a similar problem. can only get one page, if there are more items than the page read size for cosmos accessing the iterator crashes the program. I'm with Python

ncmindera avatar Feb 15 '25 16:02 ncmindera

@ncmindera I eventually found the list of features that the emulator currently supports. I guess it might be a matter of time until they implement everything

bruniela avatar Feb 15 '25 22:02 bruniela

Hello @bruniela ! Yeah I found that list although it is not accurate as per my Experience. It says that queries with order by are supported, but my query with order by doesn't work. I removed it from the query and I was able to proceed my work. Thanks for opening this issue. was very helpful!

ncmindera avatar Feb 16 '25 06:02 ncmindera

@bruniela just saw you are from Portugal, what a coincidence! If you are interested please let's connect on LinkedIn I'm going to release a package for cosmos db in the upcoming months and I hope it will help people save costs! Cheers

ncmindera avatar Feb 16 '25 06:02 ncmindera

I am facing the same issue. I think, if it is written in the list of features, that Order By is supported, than it should be supported. Is there any way to fix or workaround this issue?

sahinM avatar Feb 20 '25 20:02 sahinM