DefinitelyTyped/DefinitelyTyped · error · Error
The query wasn't accepted by the server. Try again/use conti
Error message
The query wasn't accepted by the server. Try again/use continuation token between API and script.
What it means
Line 299 in a sample stored procedure: collection.queryDocuments(collectionLink, query, opts, cb) returns a boolean isAccepted. When the server cannot accept the query — execution budget already spent, throughput saturated, or the query would exceed the request envelope — isAccepted is false and the sproc throws 'The query wasn't accepted by the server. Try again/use continuation token between API and script.' The message itself directs the caller to re-invoke with a continuation token.
Source
Thrown at types/documentdb-server/documentdb-server-tests.ts:299
function simple(prefix: string) {
var collection: ICollection = getContext().getCollection();
// Query documents and take 1st item.
var isAccepted: boolean = collection.queryDocuments(
collection.getSelfLink(),
"SELECT * FROM root r",
function(err: IFeedCallbackError, feed: any[], options: IFeedCallbackOptions) {
if (err) throw err;
// Check the feed and if it's empty, set the body to 'no docs found',
// Otherwise just take 1st element from the feed.
if (!feed || !feed.length) getContext().getResponse().setBody("no docs found");
else getContext().getResponse().setBody(prefix + JSON.stringify(feed[0]));
},
);
if (!isAccepted) {
throw new Error(
"The query wasn't accepted by the server. Try again/use continuation token between API and script.",
);
}
}
/**
* A DocumentDB stored procedure that bulk deletes documents for a given query.<br/>
* Note: You may need to execute this sproc multiple times (depending whether the sproc is able to delete every document within the execution timeout limit).
*
* @param {string} query - A query that provides the documents to be deleted (e.g. "SELECT * FROM c WHERE c.founded_year = 2008")
* @returns {Object.<number, boolean>} Returns an object with the two properties:<br/>
* deleted - contains a count of documents deleted<br/>
* continuation - a boolean whether you should execute the sproc again (true if there are more documents to delete; false otherwise).
*/
function bulkDeleteSproc(query: string) {
var collection: ICollection = getContext().getCollection();
var collectionLink: string = collection.getSelfLink();
var response: IResponse = getContext().getResponse();View on GitHub (pinned to 8f494947ae)
Solutions
- On isAccepted=false, return a continuation token to the client and re-invoke the sproc
- Pass a continuation token from requestOptions on re-invocation
- Add a WHERE clause to reduce scanned documents
- Retry externally with exponential backoff; raise RU/s if persistent
Example fix
// before
if (!isAccepted) {
throw new Error("The query wasn't accepted by the server. Try again/use continuation token between API and script.");
}
// after - signal continuation instead of throwing
if (!isAccepted) {
getContext().getResponse().setBody({ accepted: false, continuation: currentContinuation });
return;
} Defensive patterns
Strategy: retry
Validate before calling
// client side: only call when throughput headroom exists; pass last continuation
if (hasThroughputHeadroom()) { invokeSproc(lastContinuation); } else { waitAndRetry(); } Type guard
function isAcceptedBoolean(v: any): v is boolean {
return typeof v === 'boolean';
} Try / catch
if (!isAccepted) {
// do not throw — return continuation so client re-invokes
getContext().getResponse().setBody({ accepted: false, continuation: currentContinuation });
return;
} Prevention
- Design sprocs to be re-entrant with continuation tokens
- Tighten the SQL WHERE to reduce scanned documents
- Retry externally with exponential backoff
- Provision RU/s to match realistic load
When it happens
Trigger: Issuing queryDocuments when the sproc has already used most of its budget; a query over a large result set without continuation; RU contention at query submission.
Common situations: Bulk-read/bulk-delete sprocs that issue one big query; devs treat the first query as the only one and don't plan for continuation.
Related errors
- The call was not accepted
- deleteDocument was not accepted
- The array is undefined or null.
- The query is undefined or null.
- The id is undefined or null.
AI-assisted analysis of DefinitelyTyped/DefinitelyTyped@8f494947ae (2026-08-12).
Data as JSON: /api/errors/e6ab72226584a9e2.
Report an issue: GitHub.