Skip to content

docs: add JSDoc to trackInitialHost() in background.js#180

Merged
ormidales merged 1 commit into1.0.10from
copilot/patch-add-jsdoc-comment
Mar 16, 2026
Merged

docs: add JSDoc to trackInitialHost() in background.js#180
ormidales merged 1 commit into1.0.10from
copilot/patch-add-jsdoc-comment

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

trackInitialHost() implements non-trivial LRU+TTL eviction logic but had no documentation, leaving its behavioural contract implicit.

Changes

  • background.js — added JSDoc block to trackInitialHost(requestId, host):
    • Documents purpose: recording initial hostname for cross-redirect domain comparison in onHeadersReceived
    • Describes eviction strategy: prefers oldest TTL-expired entry to avoid evicting in-flight requests; falls back to oldest-inserted when no stale entry exists
    • @param annotations for both parameters, styled consistently with surrounding background.js docs (no dash, aligned descriptions)
/**
 * Records the initial hostname for a given request ID to allow cross-redirect
 * domain comparison in onHeadersReceived.
 *
 * When the map reaches MAX_TRACKED_REQUESTS, eviction prefers the oldest
 * TTL-expired entry so that live (in-flight) requests are not prematurely
 * removed during burst traffic. Falls back to evicting the oldest-inserted
 * entry only when no stale entry exists, bounding memory usage.
 *
 * @param {string} requestId The WebExtensions request identifier.
 * @param {string} host      The hostname from the original request URL.
 */
const trackInitialHost = (requestId, host) => {  }
Original prompt

This section details on the original issue you should resolve

<issue_title>[PATCH] trackInitialHost() is missing a JSDoc comment in background.js</issue_title>
<issue_description>Category: documentation
Severity: patch
File(s): background.js

Description

The trackInitialHost(requestId, host) function implements non-trivial LRU + TTL eviction logic to bound memory usage, but it has no JSDoc comment. Its eviction strategy (prefer stale entries, fall back to oldest-inserted) is a meaningful behaviour contract that deserves explicit documentation, consistent with the level of detail found in other functions in the same file.

Problematic code example

// No JSDoc above this function
function trackInitialHost(requestId, host) {
  if (initialHostByRequest.size >= MAX_TRACKED_REQUESTS) {
    // eviction logic …
  }
  initialHostByRequest.set(requestId, { host, trackedAt: Date.now() });
}

Suggested fix

/**
 * Records the initial hostname for a given request ID to allow cross-redirect
 * domain comparison in onHeadersReceived.
 *
 * When the map reaches MAX_TRACKED_REQUESTS, eviction prefers the oldest
 * TTL-expired entry so that live (in-flight) requests are not prematurely
 * removed during burst traffic. Falls back to evicting the oldest-inserted
 * entry only when no stale entry exists, bounding memory usage.
 *
 * @param {string} requestId - The WebExtensions request identifier.
 * @param {string} host      - The hostname from the original request URL.
 */
function trackInitialHost(requestId, host) {  }

Acceptance criteria

  • trackInitialHost() has a JSDoc block with @param annotations
  • The eviction strategy is described in the comment
  • Style is consistent with surrounding documentation</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] [PATCH] Add JSDoc comment for trackInitialHost function docs: add JSDoc to trackInitialHost() in background.js Mar 16, 2026
Copilot AI requested a review from ormidales March 16, 2026 09:00
@ormidales ormidales added this to the v1.0.10 milestone Mar 16, 2026
@ormidales ormidales linked an issue Mar 16, 2026 that may be closed by this pull request
3 tasks
@ormidales ormidales marked this pull request as ready for review March 16, 2026 09:01
Copilot AI review requested due to automatic review settings March 16, 2026 09:01
Copy link
Contributor

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.

Copilot wasn't able to review any files in this pull request.


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

@ormidales ormidales merged commit e081650 into 1.0.10 Mar 16, 2026
1 check passed
@ormidales ormidales deleted the copilot/patch-add-jsdoc-comment branch March 16, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PATCH] trackInitialHost() is missing a JSDoc comment in background.js

3 participants