Response Header population inconsistent
See original GitHub issueBeen trying to track down more details on this one but am pressed for time and replication is odd.
Queries that do not have parameters and do not have specific FeedOptions do not populate Response headers. Expectation is that headers always are populated in the response.headers.
Example:
let querySpec = { query: "SELECT C.id, C.company_name FROM Customers C" };
let response = await this.container.items.query(querySpec, options).toArray();
Cases when response.headers is empty based on options:
options = {}
options = { enableCrossPartitionQuery: true, populateQueryMetrics: true }
Cases when its populated
let options = { enableCrossPartitionQuery: true, populateQueryMetrics: true, maxItemCount: 1 }
p.s. maxItemCount isnt being respected either but will log a separate issue for that.
Second, if querySpec has params headers are populated. If querySpec does not have params but the query itself has something like Status = 1, headers populate.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
@dustensalinas Thanks for the report. This has come up before and it is something we do need to fix. The issue is similar to #157 in that toArray() can result in many calls to the server. If you are looking for granular metrics, your best bet is to step through the calls yourself using methods on
QueryIterator
likeexecuteNext()
orgetAsyncIterator()
. Those return headers for each request. I’m going to leave this open while I discuss with the team the best way to report headers/metrics(https://github.com/Azure/azure-cosmos-js/issues/75) on toArray() results.I’ve now run across this bug/enhancement in another project and got me thinking about it again. I think the real difficulty here is the inconsistency (ie if only one query was called then it populates vs not). Might I suggest the response headers be populated in an array? This way no odd transformations but if we call something like toarray and multiple requests were needed to populate it, we know that there are multiple headers and can address appropriately vs sometimes there and sometimes undef?