Skip to content

reduce companion redis key timeouts to 10 min#6357

Open
mifi wants to merge 4 commits into
mainfrom
redis-timeout-10min
Open

reduce companion redis key timeouts to 10 min#6357
mifi wants to merge 4 commits into
mainfrom
redis-timeout-10min

Conversation

@mifi

@mifi mifi commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9c26b46

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

This PR includes changesets to release 1 package
Name Type
@uppy/companion 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

@mifi

mifi commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

not sure if it's a breaking change. in theory it should break anything so i'm inclined to say minor

In theory this shouldn't affect users

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 reduces how long Uppy Companion keeps certain Redis-backed state around, aiming to prevent Redis space growth from long-lived keys created during uploads and (optionally) Express sessions.

Changes:

  • Reduce Express session cookie lifetime (for the Grant OAuth redirect flow) from 1 day to 10 minutes.
  • Reduce Redis TTL for per-upload progress/state keys (companion:<uuid>) from 24 hours to 10 minutes.
  • Centralize the auth-token cookie name logic via a shared getCookieName() helper.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/@uppy/companion/src/standalone/index.ts Reduces session cookie maxAge to 10 minutes (currently only when COMPANION_COOKIE_DOMAIN is set).
packages/@uppy/companion/src/server/Uploader.ts Reduces Redis TTL for upload state keys to 10 minutes.
packages/@uppy/companion/src/server/middlewares.ts Uses shared helper to compute the auth cookie name.
packages/@uppy/companion/src/server/helpers/jwt.ts Exports getCookieName() for reuse.
.changeset/purple-vans-act.md Adds a changeset entry for the patch release.

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

Comment thread packages/@uppy/companion/src/standalone/index.ts Outdated
@qxprakash

Copy link
Copy Markdown
Collaborator

@mifi can you fix lint ?

@qxprakash qxprakash left a comment

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.

code wise lgtm ! , locally tested. I just have a doubt about 1 possible edgecase which can come with reduced TTL.

saveState(state: { action: string; payload: unknown }): void {
if (!this.storage) return
// make sure the keys get cleaned up.
// We don't need more than 10 minutes because progress events should make sure that it doesn't expire before the upload is done.

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.

We don't need more than 10 minutes because progress events should make sure that it doesn't expire before the upload is done.

but this is only true while the same Companion process is alive and actively uploading right ? the moment that process dies or a reconnect lands on a different instance (behind a load balancer) redis is the only source of truth ? in that case 10 min TTL might be too small ?

I tested this locally by reducing the TTL to 15 seconds: paused an upload, waited 15 seconds, restarted Companion server , the upload stalled , can this be a bug in production ?

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.

3 participants