Fix flush method root cause - handle async callbacks in _doSend with proper error handling#2633
Merged
Fix flush method root cause - handle async callbacks in _doSend with proper error handling#2633
Conversation
Co-authored-by: MSNev <[email protected]>
Co-authored-by: MSNev <[email protected]>
Copilot
AI
changed the title
[WIP] [BUG] flush never completes
Fix flush method to properly handle callbacks and return promises
Jul 28, 2025
MSNev
reviewed
Jul 28, 2025
…mises correctly when triggerSend returns null Co-authored-by: MSNev <[email protected]>
Copilot
AI
changed the title
Fix flush method to properly handle callbacks and return promises
Fix flush method to handle callbacks and promises when triggerSend returns null
Jul 28, 2025
MSNev
reviewed
Jul 28, 2025
- Fixed _doSend to properly capture and return promises from sendPostFunc instead of always returning null - Updated flush method to use doAwaitResponse pattern as suggested - Ensures async operations properly return promises that can be awaited - Maintains backward compatibility with existing usage patterns Co-authored-by: MSNev <[email protected]>
Copilot
AI
changed the title
Fix flush method to handle callbacks and promises when triggerSend returns null
Fix flush method root cause - make _doSend return promises and use doAwaitResponse
Jul 28, 2025
MSNev
reviewed
Jul 28, 2025
Co-authored-by: MSNev <[email protected]>
Copilot
AI
changed the title
Fix flush method root cause - make _doSend return promises and use doAwaitResponse
Fix flush method root cause - handle async callbacks in _doSend and simplify return logic
Jul 28, 2025
MSNev
reviewed
Jul 28, 2025
…lling Co-authored-by: MSNev <[email protected]>
Co-authored-by: MSNev <[email protected]>
Collaborator
…ovided Co-authored-by: MSNev <[email protected]>
Contributor
Author
Fixed the failing test. The issue was that when |
MSNev
reviewed
Jul 29, 2025
Co-authored-by: MSNev <[email protected]>
MSNev
approved these changes
Jul 30, 2025
Karlie-777
approved these changes
Jul 30, 2025
JacksonWeber
approved these changes
Jul 30, 2025
MSNev
added a commit
that referenced
this pull request
Sep 3, 2025
* Add Azure API Management proxy documentation to FAQ sections (#2625) * Initial plan * Add Azure APIM proxy documentation to FAQ sections Co-authored-by: MSNev <[email protected]> * Update APIM proxy link text for clarity and consistency Co-authored-by: rads-1996 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> Co-authored-by: rads-1996 <[email protected]> * Add weekly GitHub action to delete closed and merged branches (#2627) * Initial plan * Add weekly GitHub action to delete closed and merged branches Co-authored-by: MSNev <[email protected]> * Add documentation and comments to branch cleanup workflow Co-authored-by: MSNev <[email protected]> * Add beta and otel-sdk to protected branches list Co-authored-by: MSNev <[email protected]> * Add documentation comment for GitHub context variables and environment variables Co-authored-by: MSNev <[email protected]> * Add documentation comment for GitHub API delete reference command Co-authored-by: MSNev <[email protected]> * Fix wildcard pattern matching in branch protection logic Replace case statement with [[ ]] pattern matching to properly support wildcard patterns in variables. Add documentation explaining why this approach is needed for patterns like "release*" and "*-legacy". Addresses feedback about wildcard pattern matching not working correctly. Co-authored-by: MSNev <[email protected]> * Add documentation comments for required workflow permissions Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix trackPageView not resetting maxAjaxCallsPerView counter (#2595) * Initial plan * Implement resetAjaxAttempts functionality Co-authored-by: MSNev <[email protected]> * Refactor: Create helper function for resetting ajax attempts counter Co-authored-by: MSNev <[email protected]> * Revert ajax.ts helper function, create helper in AnalyticsPlugin.ts instead Co-authored-by: MSNev <[email protected]> * Replace direct _trackAjaxAttempts assignments with helper function calls Co-authored-by: MSNev <[email protected]> * Remove comment and redundant _resetAjaxAttempts call from trackPageView Co-authored-by: MSNev <[email protected]> * Improve test consistency by matching existing test patterns Co-authored-by: MSNev <[email protected]> * Add @microsoft/applicationinsights-dependencies-js as dev dependency Co-authored-by: MSNev <[email protected]> * Fix getPlugin usage to properly access plugin through ILoadedPlugin interface Co-authored-by: MSNev <[email protected]> * Remove explicit type casting from getPlugin call Co-authored-by: MSNev <[email protected]> * Remove unused imports IDependenciesPlugin and ILoadedPlugin Co-authored-by: MSNev <[email protected]> * Fix IDependenciesPlugin interface to extend IPlugin for proper getPlugin typing Co-authored-by: MSNev <[email protected]> * Create IAjaxMonitorPlugin interface and revert Version line per review feedback Co-authored-by: MSNev <[email protected]> * Move resetAjaxAttempts method to IAjaxMonitorPlugin interface per review feedback Co-authored-by: MSNev <[email protected]> * Fix npm build failures by removing typed import dependency Co-authored-by: MSNev <[email protected]> * Fix TypeScript configuration by removing deprecated suppressImplicitAnyIndexErrors option Co-authored-by: MSNev <[email protected]> * Fix getPlugin typing to use IAjaxMonitorPlugin for proper TypeScript inference Co-authored-by: MSNev <[email protected]> * Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors Co-authored-by: MSNev <[email protected]> * Fix IAjaxMonitorPlugin export and plugin access pattern for resetAjaxAttempts Co-authored-by: MSNev <[email protected]> * Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors option Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix jq syntax error in Delete Merged Branches workflow (#2630) * Initial plan * Fix jq syntax error in Delete Merged Branches workflow Co-authored-by: MSNev <[email protected]> * Update all jq commands to single lines to avoid line splitting issues Co-authored-by: MSNev <[email protected]> * Fix closed_prs jq command to single line format Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern (#2607) * Initial plan * Update async tests in AISKULight to use modern asyncQueue pattern Co-authored-by: Karlie-777 <[email protected]> * Update AISKULight async tests to follow the suggested modern pattern with helper methods Co-authored-by: Karlie-777 <[email protected]> * Remove changes outside AISKULight directory as requested Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add() for waitForException calls in AISKULight tests Co-authored-by: Karlie-777 <[email protected]> * Move initial test setup code before asyncQueue return statement for better variable scoping Co-authored-by: Karlie-777 <[email protected]> * Remove custom helper methods and use PollingAssert.createPollingAssert directly Co-authored-by: Karlie-777 <[email protected]> * Fix async tests by replacing createPollingAssert with asyncTaskPollingAssert for modern pattern compatibility Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 167 Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 210 Co-authored-by: Karlie-777 <[email protected]> * fix: change .concat to .add on line 119 in dynamicconfig.tests.ts Co-authored-by: Karlie-777 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Karlie-777 <[email protected]> * Fix flush method root cause - handle async callbacks in _doSend with proper error handling (#2633) * Initial plan * Fix flush method to handle callbacks and return promises correctly Co-authored-by: MSNev <[email protected]> * Clean up eslint warnings and add comprehensive tests Co-authored-by: MSNev <[email protected]> * Simplify flush implementation per feedback - handle callbacks and promises correctly when triggerSend returns null Co-authored-by: MSNev <[email protected]> * Fix root cause in _doSend and use doAwaitResponse in flush method - Fixed _doSend to properly capture and return promises from sendPostFunc instead of always returning null - Updated flush method to use doAwaitResponse pattern as suggested - Ensures async operations properly return promises that can be awaited - Maintains backward compatibility with existing usage patterns Co-authored-by: MSNev <[email protected]> * Fix async callback handling in _doSend and simplify flush return logic Co-authored-by: MSNev <[email protected]> * Fix async callback handling with direct resolve capture instead of polling Co-authored-by: MSNev <[email protected]> * Handle rejection in async preparePayload callback Co-authored-by: MSNev <[email protected]> * Use doAwait with direct callbacks instead of doAwaitResponse Co-authored-by: MSNev <[email protected]> * Fix TypeScript compilation errors in Sender.ts - fix flush method signature and type casting Co-authored-by: MSNev <[email protected]> * Rename flush parameter from 'async' to 'isAsync' to avoid keyword conflicts Co-authored-by: MSNev <[email protected]> * Add unreleased changes entry to RELEASES.md for flush method fix Co-authored-by: MSNev <[email protected]> * Address code review feedback: clarify breaking changes and add comprehensive flush method tests Co-authored-by: MSNev <[email protected]> * Use isPromiseLike and isUndefined helpers in Sender tests Co-authored-by: MSNev <[email protected]> * Fix flush method to return promise when async=true and no callback provided Co-authored-by: MSNev <[email protected]> * Fix RELEASES.md to show real original flush method signature Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix issue #2634 moving the conditional check for filtering (#2635) * Fix issue #2634 moving the conditional check for filtering * refactoring * Remove additional unnecessary returns --------- Co-authored-by: Nev <[email protected]> * Ensure parent is defined before checking length in getImageHref function (#2636) Co-authored-by: pnoodles <[email protected]> * [Feature] Implement cookie caching when disabled and automatic flushing when enabled with backward compatibility option (#2632) * Initial plan * Implement cookie caching when disabled and flushing when enabled * Fix blocked cookie caching logic - blocked cookies should not be cached * Add dynamic config change support for cookie flushing * Address PR feedback: remove redundant flush, cache deletions, store formatted values * Add test coverage for deletion caching behavior * Address PR feedback: rename function, eliminate redundant calls, change operation to purge * Rename helper function to avoid recursive call - _formatSetCookieValue * Revert del() to use _formatCookieValue instead of _formatSetCookieValue * Minify cache object by using single-character property names and integer enum constants * Convert PENDING_OP constants to const enum ePendingOp * Fix cache object interface: type o as ePendingOp, remove unused p property * Fix TypeScript error: use _formatCookieValue instead of _formatSetCookieValue in del() caching * Extract common deletion values creation logic to reduce duplication * Refactor _createDeletionValues to _formatDeletionValue and simplify call sites * Update tests to reflect new cookie caching behavior when disabled * Add clock.tick(1) after configuration changes to allow dynamic config updates * Fix failing tests: Replace throw patterns with call counters in disabled cookie tests * Revert disabled cookie tests to use throw pattern instead of call counters for tests that never enable cookies * Fix cookie flushing order issue in setEnabled() method * Revert "Fix cookie flushing order issue in setEnabled() method" - This reverts commit 8da53ab. * Fix failing tests by adding clock.tick(1) after setEnabled() calls to allow async config changes * Add release notes for cookie caching feature to RELEASES.md * Add disableCaching configuration option and comprehensive test coverage * Implement PR review feedback: rename disableCaching to disableCookieCache, add @SInCE tag, optimize with local variable, set default to false * Simplify disableCookieCache configuration to use direct false value * Fix test failures by adding useFakeTimers: true to all tests using clock.tick() * Fix test failures by adding defensive null checks for this.clock.tick() calls * Revert defensive clock.tick() helper - ensure tests use useFakeTimers property * Fix tests to expect new disableCookieCache configuration property * Fix cookie flushing issue in setEnabled method - add immediate flushing for synchronous calls * Fix setEnabled method to use asynchronous configuration changes and update test with missing clock.tick * Fix test failures by adding clock.tick() after setEnabled(false) calls in all tests using fake timers * Fix test delCookie mock to set deletion value instead of deleting entry * Revert delCookie mock to use delete and fix tests to expect undefined after deletion * Fix test formatting error in cookie manager tests - proper validation of maxAge cookie flushing * Fix failing cookie manager tests - correct caching behavior expectations * Fix cookie manager tests to be order-independent for multi-parameter assertions * Fix cookie manager tests to handle order-independent cookie parameter assertions * Take Over co-pilot PR to Fix tests and change name to disableCookieDefer --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * [Main][Task] 34470593: Update AISKU Async Tests To Use the Modern AsyncQueue Pattern (#2637) * update aisku tests * udpate * [Main][Task] 34470593: Update Async Tests Under Dependencies Extension To Use the Modern AsyncQueue Pattern (#2638) * udpate * merge main * [Beta] Fix Merge issues --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: Karlie-777 <[email protected]> Co-authored-by: aimbrenda <[email protected]> Co-authored-by: Patrick <[email protected]> Co-authored-by: pnoodles <[email protected]>
MSNev
added a commit
that referenced
this pull request
Sep 3, 2025
* [Main] Update the copilot instructions (#2617) * [WIP] [Task] Add tree-shaking annotations (#2616) * Initial plan * Changes before error encountered Co-authored-by: MSNev <[email protected]> * Fix tree-shaking annotation syntax - remove incorrect parentheses Co-authored-by: MSNev <[email protected]> * Add parentheses around @__PURE__ comments in IOfflineBatch.ts Co-authored-by: MSNev <[email protected]> * Add parentheses around @__PURE__ comments for proper TypeScript handling Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Suppressed credentials inline to avoid credscan false positive (#2622) * Suppressed credentials inline to avoid credscan false positive * Used the next line supression syntax to avoid long length issue * [Beta] Add W3c Trace State support / handling and refactor distributed trace... (#2620) * [Beta] Add W3c Trace State support / handling and refactor distributed trace handling to prepare for OptenTelemetry Span style API / management * Minification improvements * [Beta] Merge Main to Beta (#2640) * Add Azure API Management proxy documentation to FAQ sections (#2625) * Initial plan * Add Azure APIM proxy documentation to FAQ sections Co-authored-by: MSNev <[email protected]> * Update APIM proxy link text for clarity and consistency Co-authored-by: rads-1996 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> Co-authored-by: rads-1996 <[email protected]> * Add weekly GitHub action to delete closed and merged branches (#2627) * Initial plan * Add weekly GitHub action to delete closed and merged branches Co-authored-by: MSNev <[email protected]> * Add documentation and comments to branch cleanup workflow Co-authored-by: MSNev <[email protected]> * Add beta and otel-sdk to protected branches list Co-authored-by: MSNev <[email protected]> * Add documentation comment for GitHub context variables and environment variables Co-authored-by: MSNev <[email protected]> * Add documentation comment for GitHub API delete reference command Co-authored-by: MSNev <[email protected]> * Fix wildcard pattern matching in branch protection logic Replace case statement with [[ ]] pattern matching to properly support wildcard patterns in variables. Add documentation explaining why this approach is needed for patterns like "release*" and "*-legacy". Addresses feedback about wildcard pattern matching not working correctly. Co-authored-by: MSNev <[email protected]> * Add documentation comments for required workflow permissions Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix trackPageView not resetting maxAjaxCallsPerView counter (#2595) * Initial plan * Implement resetAjaxAttempts functionality Co-authored-by: MSNev <[email protected]> * Refactor: Create helper function for resetting ajax attempts counter Co-authored-by: MSNev <[email protected]> * Revert ajax.ts helper function, create helper in AnalyticsPlugin.ts instead Co-authored-by: MSNev <[email protected]> * Replace direct _trackAjaxAttempts assignments with helper function calls Co-authored-by: MSNev <[email protected]> * Remove comment and redundant _resetAjaxAttempts call from trackPageView Co-authored-by: MSNev <[email protected]> * Improve test consistency by matching existing test patterns Co-authored-by: MSNev <[email protected]> * Add @microsoft/applicationinsights-dependencies-js as dev dependency Co-authored-by: MSNev <[email protected]> * Fix getPlugin usage to properly access plugin through ILoadedPlugin interface Co-authored-by: MSNev <[email protected]> * Remove explicit type casting from getPlugin call Co-authored-by: MSNev <[email protected]> * Remove unused imports IDependenciesPlugin and ILoadedPlugin Co-authored-by: MSNev <[email protected]> * Fix IDependenciesPlugin interface to extend IPlugin for proper getPlugin typing Co-authored-by: MSNev <[email protected]> * Create IAjaxMonitorPlugin interface and revert Version line per review feedback Co-authored-by: MSNev <[email protected]> * Move resetAjaxAttempts method to IAjaxMonitorPlugin interface per review feedback Co-authored-by: MSNev <[email protected]> * Fix npm build failures by removing typed import dependency Co-authored-by: MSNev <[email protected]> * Fix TypeScript configuration by removing deprecated suppressImplicitAnyIndexErrors option Co-authored-by: MSNev <[email protected]> * Fix getPlugin typing to use IAjaxMonitorPlugin for proper TypeScript inference Co-authored-by: MSNev <[email protected]> * Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors Co-authored-by: MSNev <[email protected]> * Fix IAjaxMonitorPlugin export and plugin access pattern for resetAjaxAttempts Co-authored-by: MSNev <[email protected]> * Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors option Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix jq syntax error in Delete Merged Branches workflow (#2630) * Initial plan * Fix jq syntax error in Delete Merged Branches workflow Co-authored-by: MSNev <[email protected]> * Update all jq commands to single lines to avoid line splitting issues Co-authored-by: MSNev <[email protected]> * Fix closed_prs jq command to single line format Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern (#2607) * Initial plan * Update async tests in AISKULight to use modern asyncQueue pattern Co-authored-by: Karlie-777 <[email protected]> * Update AISKULight async tests to follow the suggested modern pattern with helper methods Co-authored-by: Karlie-777 <[email protected]> * Remove changes outside AISKULight directory as requested Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add() for waitForException calls in AISKULight tests Co-authored-by: Karlie-777 <[email protected]> * Move initial test setup code before asyncQueue return statement for better variable scoping Co-authored-by: Karlie-777 <[email protected]> * Remove custom helper methods and use PollingAssert.createPollingAssert directly Co-authored-by: Karlie-777 <[email protected]> * Fix async tests by replacing createPollingAssert with asyncTaskPollingAssert for modern pattern compatibility Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 167 Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 210 Co-authored-by: Karlie-777 <[email protected]> * fix: change .concat to .add on line 119 in dynamicconfig.tests.ts Co-authored-by: Karlie-777 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Karlie-777 <[email protected]> * Fix flush method root cause - handle async callbacks in _doSend with proper error handling (#2633) * Initial plan * Fix flush method to handle callbacks and return promises correctly Co-authored-by: MSNev <[email protected]> * Clean up eslint warnings and add comprehensive tests Co-authored-by: MSNev <[email protected]> * Simplify flush implementation per feedback - handle callbacks and promises correctly when triggerSend returns null Co-authored-by: MSNev <[email protected]> * Fix root cause in _doSend and use doAwaitResponse in flush method - Fixed _doSend to properly capture and return promises from sendPostFunc instead of always returning null - Updated flush method to use doAwaitResponse pattern as suggested - Ensures async operations properly return promises that can be awaited - Maintains backward compatibility with existing usage patterns Co-authored-by: MSNev <[email protected]> * Fix async callback handling in _doSend and simplify flush return logic Co-authored-by: MSNev <[email protected]> * Fix async callback handling with direct resolve capture instead of polling Co-authored-by: MSNev <[email protected]> * Handle rejection in async preparePayload callback Co-authored-by: MSNev <[email protected]> * Use doAwait with direct callbacks instead of doAwaitResponse Co-authored-by: MSNev <[email protected]> * Fix TypeScript compilation errors in Sender.ts - fix flush method signature and type casting Co-authored-by: MSNev <[email protected]> * Rename flush parameter from 'async' to 'isAsync' to avoid keyword conflicts Co-authored-by: MSNev <[email protected]> * Add unreleased changes entry to RELEASES.md for flush method fix Co-authored-by: MSNev <[email protected]> * Address code review feedback: clarify breaking changes and add comprehensive flush method tests Co-authored-by: MSNev <[email protected]> * Use isPromiseLike and isUndefined helpers in Sender tests Co-authored-by: MSNev <[email protected]> * Fix flush method to return promise when async=true and no callback provided Co-authored-by: MSNev <[email protected]> * Fix RELEASES.md to show real original flush method signature Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix issue #2634 moving the conditional check for filtering (#2635) * Fix issue #2634 moving the conditional check for filtering * refactoring * Remove additional unnecessary returns --------- Co-authored-by: Nev <[email protected]> * Ensure parent is defined before checking length in getImageHref function (#2636) Co-authored-by: pnoodles <[email protected]> * [Feature] Implement cookie caching when disabled and automatic flushing when enabled with backward compatibility option (#2632) * Initial plan * Implement cookie caching when disabled and flushing when enabled * Fix blocked cookie caching logic - blocked cookies should not be cached * Add dynamic config change support for cookie flushing * Address PR feedback: remove redundant flush, cache deletions, store formatted values * Add test coverage for deletion caching behavior * Address PR feedback: rename function, eliminate redundant calls, change operation to purge * Rename helper function to avoid recursive call - _formatSetCookieValue * Revert del() to use _formatCookieValue instead of _formatSetCookieValue * Minify cache object by using single-character property names and integer enum constants * Convert PENDING_OP constants to const enum ePendingOp * Fix cache object interface: type o as ePendingOp, remove unused p property * Fix TypeScript error: use _formatCookieValue instead of _formatSetCookieValue in del() caching * Extract common deletion values creation logic to reduce duplication * Refactor _createDeletionValues to _formatDeletionValue and simplify call sites * Update tests to reflect new cookie caching behavior when disabled * Add clock.tick(1) after configuration changes to allow dynamic config updates * Fix failing tests: Replace throw patterns with call counters in disabled cookie tests * Revert disabled cookie tests to use throw pattern instead of call counters for tests that never enable cookies * Fix cookie flushing order issue in setEnabled() method * Revert "Fix cookie flushing order issue in setEnabled() method" - This reverts commit 8da53ab. * Fix failing tests by adding clock.tick(1) after setEnabled() calls to allow async config changes * Add release notes for cookie caching feature to RELEASES.md * Add disableCaching configuration option and comprehensive test coverage * Implement PR review feedback: rename disableCaching to disableCookieCache, add @SInCE tag, optimize with local variable, set default to false * Simplify disableCookieCache configuration to use direct false value * Fix test failures by adding useFakeTimers: true to all tests using clock.tick() * Fix test failures by adding defensive null checks for this.clock.tick() calls * Revert defensive clock.tick() helper - ensure tests use useFakeTimers property * Fix tests to expect new disableCookieCache configuration property * Fix cookie flushing issue in setEnabled method - add immediate flushing for synchronous calls * Fix setEnabled method to use asynchronous configuration changes and update test with missing clock.tick * Fix test failures by adding clock.tick() after setEnabled(false) calls in all tests using fake timers * Fix test delCookie mock to set deletion value instead of deleting entry * Revert delCookie mock to use delete and fix tests to expect undefined after deletion * Fix test formatting error in cookie manager tests - proper validation of maxAge cookie flushing * Fix failing cookie manager tests - correct caching behavior expectations * Fix cookie manager tests to be order-independent for multi-parameter assertions * Fix cookie manager tests to handle order-independent cookie parameter assertions * Take Over co-pilot PR to Fix tests and change name to disableCookieDefer --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * [Main][Task] 34470593: Update AISKU Async Tests To Use the Modern AsyncQueue Pattern (#2637) * update aisku tests * udpate * [Main][Task] 34470593: Update Async Tests Under Dependencies Extension To Use the Modern AsyncQueue Pattern (#2638) * udpate * merge main * [Beta] Fix Merge issues --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: Karlie-777 <[email protected]> Co-authored-by: aimbrenda <[email protected]> Co-authored-by: Patrick <[email protected]> Co-authored-by: pnoodles <[email protected]> * [OTel-Sdk] Update shrinkwrap from merge --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: Karlie-777 <[email protected]> Co-authored-by: aimbrenda <[email protected]> Co-authored-by: Patrick <[email protected]> Co-authored-by: pnoodles <[email protected]>
MSNev
added a commit
that referenced
this pull request
Jan 20, 2026
* [Main] Update the copilot instructions (#2617) * [WIP] [Task] Add tree-shaking annotations (#2616) * Initial plan * Changes before error encountered Co-authored-by: MSNev <[email protected]> * Fix tree-shaking annotation syntax - remove incorrect parentheses Co-authored-by: MSNev <[email protected]> * Add parentheses around @__PURE__ comments in IOfflineBatch.ts Co-authored-by: MSNev <[email protected]> * Add parentheses around @__PURE__ comments for proper TypeScript handling Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Suppressed credentials inline to avoid credscan false positive (#2622) * Suppressed credentials inline to avoid credscan false positive * Used the next line supression syntax to avoid long length issue * Add Azure API Management proxy documentation to FAQ sections (#2625) * Initial plan * Add Azure APIM proxy documentation to FAQ sections Co-authored-by: MSNev <[email protected]> * Update APIM proxy link text for clarity and consistency Co-authored-by: rads-1996 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> Co-authored-by: rads-1996 <[email protected]> * Add weekly GitHub action to delete closed and merged branches (#2627) * Initial plan * Add weekly GitHub action to delete closed and merged branches Co-authored-by: MSNev <[email protected]> * Add documentation and comments to branch cleanup workflow Co-authored-by: MSNev <[email protected]> * Add beta and otel-sdk to protected branches list Co-authored-by: MSNev <[email protected]> * Add documentation comment for GitHub context variables and environment variables Co-authored-by: MSNev <[email protected]> * Add documentation comment for GitHub API delete reference command Co-authored-by: MSNev <[email protected]> * Fix wildcard pattern matching in branch protection logic Replace case statement with [[ ]] pattern matching to properly support wildcard patterns in variables. Add documentation explaining why this approach is needed for patterns like "release*" and "*-legacy". Addresses feedback about wildcard pattern matching not working correctly. Co-authored-by: MSNev <[email protected]> * Add documentation comments for required workflow permissions Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix trackPageView not resetting maxAjaxCallsPerView counter (#2595) * Initial plan * Implement resetAjaxAttempts functionality Co-authored-by: MSNev <[email protected]> * Refactor: Create helper function for resetting ajax attempts counter Co-authored-by: MSNev <[email protected]> * Revert ajax.ts helper function, create helper in AnalyticsPlugin.ts instead Co-authored-by: MSNev <[email protected]> * Replace direct _trackAjaxAttempts assignments with helper function calls Co-authored-by: MSNev <[email protected]> * Remove comment and redundant _resetAjaxAttempts call from trackPageView Co-authored-by: MSNev <[email protected]> * Improve test consistency by matching existing test patterns Co-authored-by: MSNev <[email protected]> * Add @microsoft/applicationinsights-dependencies-js as dev dependency Co-authored-by: MSNev <[email protected]> * Fix getPlugin usage to properly access plugin through ILoadedPlugin interface Co-authored-by: MSNev <[email protected]> * Remove explicit type casting from getPlugin call Co-authored-by: MSNev <[email protected]> * Remove unused imports IDependenciesPlugin and ILoadedPlugin Co-authored-by: MSNev <[email protected]> * Fix IDependenciesPlugin interface to extend IPlugin for proper getPlugin typing Co-authored-by: MSNev <[email protected]> * Create IAjaxMonitorPlugin interface and revert Version line per review feedback Co-authored-by: MSNev <[email protected]> * Move resetAjaxAttempts method to IAjaxMonitorPlugin interface per review feedback Co-authored-by: MSNev <[email protected]> * Fix npm build failures by removing typed import dependency Co-authored-by: MSNev <[email protected]> * Fix TypeScript configuration by removing deprecated suppressImplicitAnyIndexErrors option Co-authored-by: MSNev <[email protected]> * Fix getPlugin typing to use IAjaxMonitorPlugin for proper TypeScript inference Co-authored-by: MSNev <[email protected]> * Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors Co-authored-by: MSNev <[email protected]> * Fix IAjaxMonitorPlugin export and plugin access pattern for resetAjaxAttempts Co-authored-by: MSNev <[email protected]> * Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors option Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix jq syntax error in Delete Merged Branches workflow (#2630) * Initial plan * Fix jq syntax error in Delete Merged Branches workflow Co-authored-by: MSNev <[email protected]> * Update all jq commands to single lines to avoid line splitting issues Co-authored-by: MSNev <[email protected]> * Fix closed_prs jq command to single line format Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern (#2607) * Initial plan * Update async tests in AISKULight to use modern asyncQueue pattern Co-authored-by: Karlie-777 <[email protected]> * Update AISKULight async tests to follow the suggested modern pattern with helper methods Co-authored-by: Karlie-777 <[email protected]> * Remove changes outside AISKULight directory as requested Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add() for waitForException calls in AISKULight tests Co-authored-by: Karlie-777 <[email protected]> * Move initial test setup code before asyncQueue return statement for better variable scoping Co-authored-by: Karlie-777 <[email protected]> * Remove custom helper methods and use PollingAssert.createPollingAssert directly Co-authored-by: Karlie-777 <[email protected]> * Fix async tests by replacing createPollingAssert with asyncTaskPollingAssert for modern pattern compatibility Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 167 Co-authored-by: Karlie-777 <[email protected]> * Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 210 Co-authored-by: Karlie-777 <[email protected]> * fix: change .concat to .add on line 119 in dynamicconfig.tests.ts Co-authored-by: Karlie-777 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Karlie-777 <[email protected]> * Fix flush method root cause - handle async callbacks in _doSend with proper error handling (#2633) * Initial plan * Fix flush method to handle callbacks and return promises correctly Co-authored-by: MSNev <[email protected]> * Clean up eslint warnings and add comprehensive tests Co-authored-by: MSNev <[email protected]> * Simplify flush implementation per feedback - handle callbacks and promises correctly when triggerSend returns null Co-authored-by: MSNev <[email protected]> * Fix root cause in _doSend and use doAwaitResponse in flush method - Fixed _doSend to properly capture and return promises from sendPostFunc instead of always returning null - Updated flush method to use doAwaitResponse pattern as suggested - Ensures async operations properly return promises that can be awaited - Maintains backward compatibility with existing usage patterns Co-authored-by: MSNev <[email protected]> * Fix async callback handling in _doSend and simplify flush return logic Co-authored-by: MSNev <[email protected]> * Fix async callback handling with direct resolve capture instead of polling Co-authored-by: MSNev <[email protected]> * Handle rejection in async preparePayload callback Co-authored-by: MSNev <[email protected]> * Use doAwait with direct callbacks instead of doAwaitResponse Co-authored-by: MSNev <[email protected]> * Fix TypeScript compilation errors in Sender.ts - fix flush method signature and type casting Co-authored-by: MSNev <[email protected]> * Rename flush parameter from 'async' to 'isAsync' to avoid keyword conflicts Co-authored-by: MSNev <[email protected]> * Add unreleased changes entry to RELEASES.md for flush method fix Co-authored-by: MSNev <[email protected]> * Address code review feedback: clarify breaking changes and add comprehensive flush method tests Co-authored-by: MSNev <[email protected]> * Use isPromiseLike and isUndefined helpers in Sender tests Co-authored-by: MSNev <[email protected]> * Fix flush method to return promise when async=true and no callback provided Co-authored-by: MSNev <[email protected]> * Fix RELEASES.md to show real original flush method signature Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix issue #2634 moving the conditional check for filtering (#2635) * Fix issue #2634 moving the conditional check for filtering * refactoring * Remove additional unnecessary returns --------- Co-authored-by: Nev <[email protected]> * Ensure parent is defined before checking length in getImageHref function (#2636) Co-authored-by: pnoodles <[email protected]> * [Feature] Implement cookie caching when disabled and automatic flushing when enabled with backward compatibility option (#2632) * Initial plan * Implement cookie caching when disabled and flushing when enabled * Fix blocked cookie caching logic - blocked cookies should not be cached * Add dynamic config change support for cookie flushing * Address PR feedback: remove redundant flush, cache deletions, store formatted values * Add test coverage for deletion caching behavior * Address PR feedback: rename function, eliminate redundant calls, change operation to purge * Rename helper function to avoid recursive call - _formatSetCookieValue * Revert del() to use _formatCookieValue instead of _formatSetCookieValue * Minify cache object by using single-character property names and integer enum constants * Convert PENDING_OP constants to const enum ePendingOp * Fix cache object interface: type o as ePendingOp, remove unused p property * Fix TypeScript error: use _formatCookieValue instead of _formatSetCookieValue in del() caching * Extract common deletion values creation logic to reduce duplication * Refactor _createDeletionValues to _formatDeletionValue and simplify call sites * Update tests to reflect new cookie caching behavior when disabled * Add clock.tick(1) after configuration changes to allow dynamic config updates * Fix failing tests: Replace throw patterns with call counters in disabled cookie tests * Revert disabled cookie tests to use throw pattern instead of call counters for tests that never enable cookies * Fix cookie flushing order issue in setEnabled() method * Revert "Fix cookie flushing order issue in setEnabled() method" - This reverts commit 8da53ab. * Fix failing tests by adding clock.tick(1) after setEnabled() calls to allow async config changes * Add release notes for cookie caching feature to RELEASES.md * Add disableCaching configuration option and comprehensive test coverage * Implement PR review feedback: rename disableCaching to disableCookieCache, add @SInCE tag, optimize with local variable, set default to false * Simplify disableCookieCache configuration to use direct false value * Fix test failures by adding useFakeTimers: true to all tests using clock.tick() * Fix test failures by adding defensive null checks for this.clock.tick() calls * Revert defensive clock.tick() helper - ensure tests use useFakeTimers property * Fix tests to expect new disableCookieCache configuration property * Fix cookie flushing issue in setEnabled method - add immediate flushing for synchronous calls * Fix setEnabled method to use asynchronous configuration changes and update test with missing clock.tick * Fix test failures by adding clock.tick() after setEnabled(false) calls in all tests using fake timers * Fix test delCookie mock to set deletion value instead of deleting entry * Revert delCookie mock to use delete and fix tests to expect undefined after deletion * Fix test formatting error in cookie manager tests - proper validation of maxAge cookie flushing * Fix failing cookie manager tests - correct caching behavior expectations * Fix cookie manager tests to be order-independent for multi-parameter assertions * Fix cookie manager tests to handle order-independent cookie parameter assertions * Take Over co-pilot PR to Fix tests and change name to disableCookieDefer --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * [Main][Task] 34470593: Update AISKU Async Tests To Use the Modern AsyncQueue Pattern (#2637) * update aisku tests * udpate * [Main][Task] 34470593: Update Async Tests Under Dependencies Extension To Use the Modern AsyncQueue Pattern (#2638) * udpate * merge main * [Main][Task] 27922617: Provide Custom Provider Under Web Worker for Offline Channel (#2649) * add customer provider * update * [Release] Increase version to 3.3.10 (#2650) * release 3.3.10 * update * [Main][Task] 35656109: [Snippet] Fix Snippet Loader Error (#2659) * fix snippet * udpate * update * @microsoft/applicationinsights-web-snippet 1.2.3 release (#2662) * @microsoft/applicationinsights-web-snippet 1.2.3 release * Update RELEASES.md Co-authored-by: Copilot <[email protected]> * Update * Update --------- Co-authored-by: Copilot <[email protected]> * Fix static web CDN test assertion (Fixes failing CI tests) (#2670) * Fix static web CDN test assertion * Modify logic for test * Add fail assertion * Add a check to prevent non-string URLs from being passed to fieldRedaction method (#2667) * Add a check to prevent non-string URLs from being passed tO fieldRedaction * Move the check to the fieldredaction method * Update shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts removed unused config Co-authored-by: Copilot <[email protected]> * Updated fieldRedaction method with string check * Retrigger CI/CD pipeline * Retrigger CI/CD pipeline * Retrigger CI/CD pipeline --------- Co-authored-by: Copilot <[email protected]> * Fix offline channel recovery for Offline -> Online (#2674) (#2675) * Fix unload() to return promise when called without parameters (#2666) * Initial plan * Fix unload function to return promise by default and add tests Co-authored-by: MSNev <[email protected]> * Use isPromiseLike helper in unload tests Co-authored-by: MSNev <[email protected]> * Fix TypeScript errors in test cases - use testCase instead of testCaseAsync Co-authored-by: MSNev <[email protected]> * Remove unused strSubstring import Co-authored-by: MSNev <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MSNev <[email protected]> * Fix Flakey Ajax test which has race condition (#2676) * Separate BeaconSendFailure and BeaconSendFailure from SizeLimitExceeded (#2642) * Separate BeaconSendFailure and BeaconSendFailure from SizeLimitExceeded to make it easier to troubleshoot SizeLimitExceeded errors * PR feedback * Add redact URL configuration in readme (#2681) * Add redact URL configuration in readme * Update README.md Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix minor issue with E2E test (#2684) * [Release] Increase version to 3.3.11 (#2687) --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: Karlie-777 <[email protected]> Co-authored-by: aimbrenda <[email protected]> Co-authored-by: Patrick <[email protected]> Co-authored-by: pnoodles <[email protected]> Co-authored-by: Hector Hernandez <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: rads-1996 <[email protected]> Co-authored-by: Philip Peitsch <[email protected]> Co-authored-by: Ryan Gammon <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Sender.flush()method was not properly handling callbacks or returning promises because the root cause was in the_doSend()function, which couldn't handle asynchronous callbacks frompreparePayload().Root Cause
The issue was that
_doSend()assumedpreparePayload()would always execute its callback synchronously, but when compression is enabled, the callback executes asynchronously after stream processing completes.Solution
Fixed
_doSend()to handle both synchronous and asynchronous callback execution using direct resolve capture with proper error handling:Also simplified the flush method's return logic using
doAwaitResponseto handle both promise and non-promise results consistently.Breaking Changes
This release contains a potential breaking change to the
flushmethod signature in theIChannelControlsinterface. The parameter name has been changed fromasynctoisAsyncto avoid potential conflicts with theasynckeyword.Interface change:
If you have custom channels or plugins that implement the
IChannelControlsinterface directly, you will need to update the parameter name fromasynctoisAsyncin your implementation.Benefits
await applicationInsights.flush()now works correctly with compression enabledscheduleTimeoutpollingpreparePayloadexecutes callback immediately or asynchronouslyFixes #2628.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.