Skip to content

FR: respond to long polling after 29 seconds instead of 30, or make it configurable #6987

@ZYinMD

Description

@ZYinMD

This was discussed with @sampajano in #1674.

Background:
OnSnapshot listeners normally use websocket (I think), but if client is behind a proxy that doesn't support websocket, the sdk can use long polling instead. This can be configured with experimentalForceLongPolling and experimentalAutoDetectLongPolling, and the latter may soon be turned on by default.

My observation:
When there's no new change on the doc, after 30 seconds the server will respond "no change" to the long poll.
image

However, if the proxy happens to be AWS API Gateway, which happens to enforce a timeout of exactly 30 seconds, the poll result will be just a hair too slow to return in time:
image

The problem:
It's a benign error, but it bombards the console every 30 seconds, and the wording isn't so benign:
image

Proposal:

  • Respond to long polls after 29 seconds instead of 30, for the sake of AWS API Gateway (low hanging fruit)
  • or make it configurable (could be over engineering if nobody uses it)

Very easy to reproduce:

// good normal long polling without proxy:
initializeFirestore(app, {
  experimentalForceLongPolling: true, 
});

// with proxy in the middle:
initializeFirestore(app, {
  host: `6i558xin74.execute-api.us-west-1.amazonaws.com`,
  // ↑ my production-ready proxy, everybody feel free to use!!
  experimentalAutoDetectLongPolling: true, 
});

More info:
AWS 30s limit:
image

More info:
No "server" header, indicating the proxy returned 503 to client before firestore server returned anything to proxy:
image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions