Skip to content

Conversation

Copy link

Copilot AI commented Feb 1, 2026

The subscribe() method uses a manual performance.getEntriesByType() workaround instead of the native buffered option, but documentation was unclear about why.

Changes

  • captureBufferedEntries option: Simplified documentation to explain the manual approach using performance.getEntriesByType() and note that the native buffered option is unreliable in Node.js
  • subscribe() method: Added concise explanation that buffered entries are captured via performance.getEntriesByType() instead of the unreliable native buffered option
  • Inline comments: Replaced vague "for unknown reasons not working" comment with clear reference to the unreliable native option

The documentation now concisely explains why the manual approach is used (native buffered option unreliability) without extensive detail about guarantees, limitations, or memory management.


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

…d limitations

Co-authored-by: BioPhoton <10064416+BioPhoton@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 1, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cloud.nx.app
    • Triggering command: /usr/local/bin/node node ./bin/post-install (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/cli/cli/node_modules/.bin/nx unit-test utils --testFile=performance-observer.unit.test.ts logs/user.env (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/cli/cli/node_modules/.bin/nx int-test utils --testFile=performance-observer.int.test.ts (dns block)
  • www.googleapis.com
    • Triggering command: /usr/local/bin/node node install.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback from review on sharded WAL refactor PR docs(utils): clarify buffered mode implementation in PerformanceObserverSink Feb 1, 2026
Copilot AI requested a review from BioPhoton February 1, 2026 22:04
@BioPhoton BioPhoton marked this pull request as ready for review February 1, 2026 23:34
Comment on lines 323 to 351
* ## Buffered Mode Implementation
*
* When `captureBufferedEntries` is true, this method captures all performance entries
* that exist in the Node.js performance buffer at the time of subscription.
*
* **Why Manual Approach:**
* The standard `buffered: true` option in PerformanceObserver.observe() is not used
* because it has proven unreliable in Node.js environments. Instead, we use
* `performance.getEntriesByType()` to manually retrieve buffered entries.
*
* **Guarantees:**
* - All marks and measures in the performance buffer at subscription time will be captured
* - Entries are processed synchronously before the observer begins watching for new entries
* - No entries created after subscription will be missed (observer handles them)
*
* **Limitations:**
* - Potential for duplicate processing if an entry exists both in the buffer and is
* delivered by the observer callback (though Node.js typically avoids this)
* - Performance buffer has a limited size; very old entries may have been evicted by Node.js
* - The manual approach captures a snapshot at subscription time; there's a small race
* condition window where entries created during getEntriesByType() execution might
* be captured by both the manual call and the observer
*
* **Memory Management:**
* Applications should call `performance.clearMarks()` and `performance.clearMeasures()`
* periodically to prevent the Node.js performance buffer from growing unbounded.
* This is especially important when using buffered mode, as the entire buffer is
* processed on subscription.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Too muh test. could you reduce it to 1 sentence @copilot

Copy link
Author

Choose a reason for hiding this comment

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

Reduced the extensive documentation section to one concise sentence that explains the manual approach and why the native option isn't used. Changes in commit 37cc84e.

Co-authored-by: BioPhoton <10064416+BioPhoton@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 1, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cloud.nx.app
    • Triggering command: /usr/local/bin/node node ./bin/post-install (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/cli/cli/node_modules/.bin/nx unit-test utils --testFile=performance-observer.unit.test.ts (dns block)
  • www.googleapis.com
    • Triggering command: /usr/local/bin/node node install.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from BioPhoton February 1, 2026 23:39
@BioPhoton BioPhoton merged commit 9daa856 into feat/utils/sharded-profiling Feb 2, 2026
@BioPhoton BioPhoton deleted the copilot/sub-pr-1231-again branch February 2, 2026 00:30
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.

2 participants