Skip to content

Commit cd54ce3

Browse files
thomasballingerConvex, Inc.
authored andcommitted
More aggressive transition message logging (#41241)
Make console logs a bit more chatty to call out large and slow transition messages. GitOrigin-RevId: 0961943134336fcfda2dbf991e84b7198d720df5
1 parent aa1e124 commit cd54ce3

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/browser/sync/web_socket_manager.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,22 +689,24 @@ export class WebSocketManager {
689689
`received ${prettyMessageMB} transition in ${prettyTransitionTime} at ${prettyBytesPerSecond}`,
690690
);
691691

692-
// Warnings that will show up for *all users*, so these are not very aggressive goals.
693-
if (transitionTransitTime > 10_000 && messageLength > 10_000_000) {
692+
// Warnings that will show up for *all users*, so don't be too aggressive.
693+
// These can be silenced (along with reconnection messages) by setting `logger: false` in client options.
694+
if (messageLength > 20_000_000) {
695+
// Big enough that the developer should be made aware of this.
694696
this.logger.log(
695-
`received query results totalling more than 10MB (${prettyMessageMB}) which took more than 10s (${prettyTransitionTime}) to arrive`,
696-
);
697-
} else if (messageLength > 20_000_000) {
698-
this.logger.log(
699-
`received query results totalling more that 20MB (${prettyMessageMB}) which will take a long time to download on slower connections`,
697+
`received query results totaling more that 20MB (${prettyMessageMB}) which will take a long time to download on slower connections`,
700698
);
701699
} else if (transitionTransitTime > 20_000) {
700+
// Long enough that a pattern of these should be interesting to a developer, but be aware that
701+
// weak connections, putting clients to sleep, backgrounding etc. could all cause this too.
702702
this.logger.log(
703-
`received query results totalling ${prettyMessageMB} which took more than 20s to arrive (${prettyTransitionTime})`,
703+
`received query results totaling ${prettyMessageMB} which took more than 20s to arrive (${prettyTransitionTime})`,
704704
);
705705
}
706+
706707
if (this.debug) {
707-
if (transitionTransitTime > 10_000 || messageLength > 10_000_000) {
708+
// debug means "reportDebugInfoToConvex" is set so this can be aggressive.
709+
if (transitionTransitTime > 2_000) {
708710
this.sendMessage({
709711
type: "Event",
710712
eventType: "ClientReceivedTransition",

0 commit comments

Comments
 (0)