Skip to content

fix: Resolve flaky test ParseLiveQuery handle invalid websocket payload length#10241

Open
AbdullahZulfiqar2005 wants to merge 2 commits intoparse-community:alphafrom
AbdullahZulfiqar2005:fix-flaky-test-9272-v2
Open

fix: Resolve flaky test ParseLiveQuery handle invalid websocket payload length#10241
AbdullahZulfiqar2005 wants to merge 2 commits intoparse-community:alphafrom
AbdullahZulfiqar2005:fix-flaky-test-9272-v2

Conversation

@AbdullahZulfiqar2005
Copy link

@AbdullahZulfiqar2005 AbdullahZulfiqar2005 commented Mar 18, 2026

Pull Request

Issue

Closes #9272

Approach

The ParseLiveQuery handle invalid websocket payload length test was marked as flaky due to random timeout errors in the CI environment. This was caused by mixing an async function declaration with a done callback, which confuses the testing framework and can lead to hung tests if events are delayed.

Fix:

  • Removed the done callback and converted the test to a standard async/await flow.
  • Wrapped the websocket subscription.on('update') event listener in a Promise to ensure the test explicitly and safely awaits the event resolution.
  • Replaced the disconnected setTimeout with an awaited Promise delay to ensure server reconfiguration and payload simulation occur sequentially.

Tasks

(No tasks apply as this is a fix to an existing test case).

Summary by CodeRabbit

  • Tests
    • Converted callback-style async tests to promise-based signaling.
    • Replaced ad-hoc timeout flow with an explicit short sleep before modifying and saving test data.
    • Replaced done() callbacks with promise resolution tied to the update event, improving reliability and maintainability.

Copilot AI review requested due to automatic review settings March 18, 2026 19:44
@parse-github-assistant
Copy link

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Mar 18, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85b78dc0-f900-41df-9c0e-b4fdd84c6958

📥 Commits

Reviewing files that changed from the base of the PR and between c2bd02c and 8eb3478.

📒 Files selected for processing (1)
  • spec/ParseLiveQuery.spec.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • spec/ParseLiveQuery.spec.js

📝 Walkthrough

Walkthrough

Convert a flaky test in spec/ParseLiveQuery.spec.js from callback-based completion (done()) to promise-based async/await, replace a setTimeout flow with an explicit awaited sleep, and use updatePromise to resolve when the 'update' event fires.

Changes

Cohort / File(s) Summary
Test Async Pattern Modernization
spec/ParseLiveQuery.spec.js
Refactored the "handle invalid websocket payload length" test: replaced callback done() signaling with a promise (updatePromise) and async/await, substituted setTimeout flow with sleep(1000), and ensured test completion via promise resolution on the 'update' event.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • PR #10133: Modifies spec/ParseLiveQuery.spec.js to replace callback-style done() signaling with promise/async handling.
  • PR #9694: Adjusts spec/ParseLiveQuery.spec.js to replace setTimeout/callback flows with awaited sleeps and explicit event awaiting.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: resolving a flaky test in ParseLiveQuery for the invalid websocket payload length scenario.
Description check ✅ Passed The description includes the required Issue section (Closes #9272) and a detailed Approach explaining the root cause and specific fixes applied to the test.
Linked Issues check ✅ Passed The changes directly address issue #9272 by converting the flaky test from a callback-based async implementation to a promise-based async/await pattern, which resolves the timeout issues.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the single flaky test in ParseLiveQuery.spec.js; no unrelated modifications are present in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR resolves CI flakiness in the ParseLiveQuery handle invalid websocket payload length spec by removing the mixed async/done pattern and making the test’s sequencing fully async/await-driven.

Changes:

  • Converted the test from async done => { ... done() } to a pure async () => { ... } flow.
  • Awaited the LiveQuery update event via a Promise rather than relying on callback completion.
  • Replaced a detached setTimeout mutation/save with an awaited delay to enforce sequential execution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix flaky test ParseLiveQuery handle invalid websocket payload length

4 participants