fix: address PR #305 review comments — Origin header, lowServerCount threshold, keepalive guard
- history.ts: add Origin: DEFAULT_ORIGIN to CDN DELETE request headers — the download path injects it internally but options does not carry it - socket.ts: fix lowServerCount comparison — was preKeyCount <= topUpAmount which triggered uploads even when above MIN_PREKEY_COUNT (e.g. 250 prekeys → topUp=550 → 250<=550=true → unnecessary upload). Now uses correct threshold: preKeyCount < MIN_PREKEY_COUNT - socket.ts: guard scheduleNextKeepAlive() with !closed check to prevent orphan timers when end() was called concurrently on a different path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
import { toNumber } from './generics'
|
||||
import type { ILogger } from './logger.js'
|
||||
import { normalizeMessageContent } from './messages'
|
||||
import { DEFAULT_ORIGIN } from '../Defaults'
|
||||
import { downloadContentFromMessage, getUrlFromDirectPath } from './messages-media'
|
||||
|
||||
const inflatePromise = promisify(inflate)
|
||||
@@ -430,7 +431,11 @@ export const downloadAndProcessHistorySyncNotification = async (
|
||||
// processing throws — the server copy would be gone and retry after reconnect would fail.
|
||||
if (msg.directPath) {
|
||||
const cdnUrl = getUrlFromDirectPath(msg.directPath)
|
||||
fetch(cdnUrl, { ...options, method: 'DELETE' }).catch(() => {
|
||||
fetch(cdnUrl, {
|
||||
...options,
|
||||
method: 'DELETE',
|
||||
headers: { ...((options as RequestInit).headers ?? {}), Origin: DEFAULT_ORIGIN }
|
||||
}).catch(() => {
|
||||
// non-fatal — server will expire it anyway
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user