Skip to content

Post each Hardcover quote once and space out Hardcover requests - #160

Merged
itsthisjustin merged 2 commits into
mainfrom
fix/hardcover-rate-limit-quotes
Nov 29, 2026
Merged

itsthisjustin merged 2 commits into
mainfrom
fix/hardcover-rate-limit-quotes

Conversation

@itsthisjustin

@itsthisjustin itsthisjustin commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Before: pressing Sync now, or the reader uploading a clipping again, queued quotes that Hardcover already had. Each push creates a new journal entry, so every retry from the portal posted another copy. A drain also sent Hardcover many requests in a row, and it answered 429 after about 10.

After: a clipping that Hardcover already has, or that is already queued with the same text and note, is not queued again. An edited note still posts a new quote. Matching the book to a different Hardcover book lets its quotes go to the new book. Hardcover requests on one token go out at most once a second.

How: a new highlightsAppendOnly connector flag, set only on Hardcover, makes fan-out and backfill skip a highlight row that is done or pending with the same text and note. saveMatch() clears delivered highlight rows when the matched book changes. gql() reserves a send slot per token, 1 s apart (HARDCOVER_MIN_GAP_MS, set to 0 in vitest.config.ts). The new tests fail on the old code.

Fixes #158

Sync now and re-uploaded clippings queued quotes that Hardcover already
had, and each push posts a new journal entry, so retries from the portal
made copies. A clipping already delivered or queued with the same text
and note is no longer queued again for Hardcover.

Hardcover returns 429 after about 10 requests in a short burst, and one
progress push makes several. Requests on one token now go out at most
once a second.

Fixes #158
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T22:40:52.631816Z ba6aab1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a7dd280-a9f1-4f3f-963d-3e0f05d18e40
Commits

Reviewing files that changed from the base of the PR and between 50ce3d7 and ba6aab1.

Files selected for processing: 8

  • src/connectors/fanout.ts
  • src/connectors/hardcover.ts
  • src/connectors/queue.ts
  • src/connectors/store.ts
  • src/connectors/types.ts
  • test/connectors-more.test.ts
  • test/connectors.test.ts
  • vitest.config.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f813a540b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/connectors/queue.ts
Comment on lines +95 to +100
`SELECT payload FROM connector_queue
WHERE user_id = ? AND connector_id = ? AND document = ? AND kind = ? AND status IN ('done', 'pending')`
).get(userId, connectorId, document, kind) as { payload: string } | undefined;
if (!row) return false;
const prev = (JSON.parse(row.payload) as OutboundEvent).highlight;
return prev?.text === h?.text && (prev?.note ?? null) === (h?.note ?? null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope delivered-quote deduplication to the remote destination

If a quote was delivered under an incorrect Hardcover book match, correcting that match and pressing “Sync now” now skips the quote permanently: this lookup treats the old book's done row as proof that the new book already has it. The manual-match route in src/routes/v1/connectors.ts calls saveMatch(), which updates connector_matches without invalidating queue rows, and neither the stored event nor this comparison records the destination book ID. Re-uploading the unchanged clipping is also suppressed. Track the destination associated with successful delivery, or invalidate the relevant delivery marker when the destination changes, so correcting a match can populate the correct book.

Useful? React with 👍 / 👎.

A quote delivered to the old book never reached the new one, so a new
match clears its delivered clippings and Sync now sends them to it.
@itsthisjustin
itsthisjustin merged commit 55ad8ae into main Nov 29, 2026
5 checks passed
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.

Hardcover: bursts of requests get HTTP 429, and quotes seem to be created even on 429, so retries create duplicates (follow-up to #148 / #150)

1 participant