Skip to content

fix: stop infinite polling when BlobImport progress returns NOT_FOUND#1501

Closed
blackcat wants to merge 4 commits intomainfrom
fix/upload-progress-infinite-poll
Closed

fix: stop infinite polling when BlobImport progress returns NOT_FOUND#1501
blackcat wants to merge 4 commits intomainfrom
fix/upload-progress-infinite-poll

Conversation

@blackcat
Copy link
Copy Markdown
Contributor

@blackcat blackcat commented Mar 11, 2026

Summary

  • Fixed infinite polling loop in UploadDriver when getStatus returns NOT_FOUND for deleted/aborted resources
  • isProgressDone() required both p.done AND p.status.progress >= 1.0, but terminal errors only set done=true without updating status — causing the task to be re-polled indefinitely
  • Downgraded log from warn to info since resource deletion/abort is expected behavior, not an error

Root cause

When Progress/GetStatus returns NOT_FOUND (resource deleted or aborted), updateStatus() calls setDone(true) which sets progress.done = true. However, isProgressDone() also checked status.progress >= 1.0. Since status was never set in the error path (or was still at a partial value), isProgressDone() returned false, keeping the task in the polling loop. Each poll produced another NOT_FOUND → another Sentry warning → 70K+ events.

Test plan

  • Build passes (pnpm turbo run build --filter=@milaboratories/pl-drivers)
  • Existing integration tests in upload.test.ts cover the normal upload/index flows
  • Manual: trigger a BlobImport, then delete the resource mid-import — verify no repeated warnings in logs

Fixes PLATFORM-ELECTRON-KC2

When getStatus returns NOT_FOUND for a deleted/aborted resource,
setDone(true) was called but isProgressDone still returned false
because it also required status.progress >= 1.0. Since status was
never set in the error path, the task kept being polled indefinitely,
producing 70K+ Sentry events.

Fix isProgressDone to only check p.done, and downgrade the log from
warn to info since resource deletion is expected behavior.

Fixes PLATFORM-ELECTRON-KC2
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 2620c6a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@milaboratories/pl-drivers Patch
@milaboratories/pl-middle-layer Patch
@platforma-sdk/test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where the UploadDriver would enter an infinite polling loop and generate excessive warnings when a BlobImport resource was deleted or aborted. By refining the logic that determines if a progress task is complete and adjusting the logging severity for expected termination scenarios, the change prevents unnecessary resource consumption and improves system stability.

Highlights

  • Polling Loop Fix: Resolved an infinite polling loop in UploadDriver that occurred when getStatus returned NOT_FOUND for deleted or aborted resources.
  • Progress Check Logic: Modified the isProgressDone() function to correctly identify completion by only checking the done property, as terminal errors set done=true without updating status.progress.
  • Logging Level Adjustment: Downgraded the log level from warn to info for terminal BlobImport errors, as resource deletion or abortion is expected behavior rather than an error.
Changelog
  • @milaboratories/pl-drivers
    • Fixed infinite polling when BlobImport progress returns NOT_FOUND.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses the infinite polling issue when a BlobImport progress returns NOT_FOUND. The change to isProgressDone() correctly ensures that tasks are marked as complete when p.done is true, preventing indefinite re-polling. Additionally, downgrading the log level from warn to info for expected terminal states like resource deletion or abortion is a good improvement for log clarity, reducing potential alert fatigue. The changes are well-explained and directly resolve the identified root cause.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.72%. Comparing base (15959f8) to head (88bf662).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/node/pl-drivers/src/drivers/upload_task.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1501      +/-   ##
==========================================
+ Coverage   54.69%   54.72%   +0.02%     
==========================================
  Files         242      242              
  Lines       13587    13587              
  Branches     2789     2789              
==========================================
+ Hits         7432     7435       +3     
+ Misses       5225     5221       -4     
- Partials      930      931       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

function isProgressDone(p: sdk.ImportProgress) {
return p.done && (p.status?.progress ?? 0.0) >= 1.0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are you sure that was a dead code?

When a BlobImport resource is deleted or aborted (NOT_FOUND/ABORTED),
PlFileInput was incorrectly showing a success state (green checkmark,
100% progress bar) because it only checked `done` for completion.

Add `aborted` field to ImportProgress so the UI can distinguish
successful completion from server-side termination. PlFileInput now
shows the error icon with the actual error message when aborted.
* was deleted or aborted on the server (e.g. NOT_FOUND / ABORTED). */
aborted?: boolean;
/** Status of indexing/uploading got from platforma gRPC. */
status?: ImportStatus;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we keep in status all statesd? done/aborted/progress/etc?

@blackcat blackcat closed this Apr 14, 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.

4 participants