mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
20f4e4263afc0e3a8af2c126ae075536f890e2a8
4 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c1dff11fa1 | refactor: optimize debounced save functionality (#7495) | ||
|
|
f5e437adaf |
fix: enable SSL session caching and HTTP agent reuse for faster consecutive requests (#6987)
* fix: enable SSL session caching for faster consecutive requests (#6929) * fix: enable SSL session caching for faster consecutive requests Previously, Bruno created a new HTTPS agent for every request, which meant SSL/TLS sessions couldn't be reused. This caused the full TLS handshake (~450ms) to run on every request, even to the same endpoint. Changes: - Add agent caching based on TLS configuration (certs, proxy, SSL options) - Reuse cached agents for requests with matching configuration - SSL sessions are now cached and reused, significantly reducing response time for consecutive requests to the same host The fix maintains backward compatibility: - Timeline logging moved to setup phase (before agent creation) - Proxy and SSL validation behavior unchanged - Added clearAgentCache() for testing and configuration changes Fixes #5574 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address review feedback for SSL session caching - Add passphrase to cache key to prevent incorrect agent reuse - Add MAX_AGENT_CACHE_SIZE (100) with LRU-style eviction - Use consistent node: prefix for crypto import Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: lohit <lohit@usebruno.com> * feat(bruno-requests): add timeline agent for TLS event logging Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(bruno-requests): add agent cache for SSL session reuse Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(bruno-requests): add tests for agent cache Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(bruno-requests): integrate agent cache into http-https-agents Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(bruno-electron): use shared agent cache from bruno-requests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(bruno-cli): use agent cache for SSL session reuse Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(bruno-requests): add HTTP agent timeline support Add createTimelineHttpAgentClass for logging HTTP connection events including proxy usage, DNS lookups, and connection establishment. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(bruno-requests): extract shared agent caching logic Add getOrCreateAgentInternal helper to reduce code duplication between getOrCreateAgent and getOrCreateHttpAgent functions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(bruno-requests): use HTTP agent cache for connection reuse Export getOrCreateHttpAgent and use it in http-https-agents for HTTP requests to enable connection pooling. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(bruno-cli): improve HTTP agent handling and error logging - Use { keepAlive: true } instead of tlsOptions for HTTP agents - Add warning log for system proxy configuration errors - Fix brace style consistency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(bruno-electron): improve HTTP agent handling - Use { keepAlive: true } instead of tlsOptions for HTTP agents - Fix brace style consistency - Add missing newline at EOF Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(bruno-requests): address code review findings for agent caching - Fix Buffer hashing bug: properly handle Buffer values in hashValue() - Add CA array support: new hashCaValue() handles string[] | Buffer[] - Fix timeline race condition: capture timeline reference in closure at createConnection start to isolate concurrent requests - Fix SSL verify message: check socket.authorized for accurate status - Fix HTTP/HTTPS agent logic: only set httpsAgent for HTTPS requests - Add tests for concurrent requests timeline isolation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(bruno-requests): log when reusing cached agent - HTTPS agents: "Reusing cached agent (SSL session reuse enabled)" - HTTP agents: "Reusing cached agent (connection reuse enabled)" Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(preferences): add cache.httpHttpsAgents.enabled preference * feat(agent-cache): add disableCache option to getOrCreateAgent * feat(proxy-util): respect httpHttpsAgents cache preference * refactor(agent-cache): use named props for getOrCreateAgent and getOrCreateHttpAgent * feat(ipc): add renderer:clear-http-https-agent-cache handler * feat(redux): add cache.httpHttpsAgents preferences to initial state * feat(ui): add Cache tab to Preferences * feat(cli): add --disable-http-https-agents-cache flag * refactor(cache): replace window.ipcRenderer calls with redux actions Add getCacheStats, purgeCache, and clearHttpHttpsAgentCache thunks to the app slice. Update the Cache preferences component to dispatch these actions instead of calling window.ipcRenderer directly. Also move handleSave and handleSaveRef above useFormik to fix declaration order — onSubmit closes over handleSaveRef, so the ref must be initialized before useFormik is called. * fix: tests * fix(cache): thread disableCache and hostname through all agent-creation paths - Forward disableHttpHttpsAgentsCache through getHttpHttpsAgents → createAgents so OAuth2 token requests and bru.sendRequest honour the CLI flag - Add hostname to agent cache keys (getAgentCacheKey, getHttpAgentCacheKey) for per-host TLS session reuse; extract hostname at every call site in run-single-request.js, proxy-util.js, and http-https-agents.ts - Add extractHostname helper in http-https-agents.ts to safely parse hostnames - Add test coverage for cert, key, pfx, passphrase, and hostname cache-key differentiation in agent-cache.spec.ts * refactor(cache): rename getOrCreateAgent to getOrCreateHttpsAgent * refactor: simplify UI labels, optimize agent timeline wrapping, silence proxy errors * fix: tests * fix(proxy): fix proxy agent construction and CA cert handling Three fixes: 1. Proxy agents (HttpsProxyAgent, HttpProxyAgent, SocksProxyAgent) expect (proxyUri, options) constructor signature, but the agent cache was packing proxyUri into options as a single argument. Fixed the non-timeline code path in getOrCreateAgentInternal. 2. HTTP requests through an HTTPS proxy need TLS options (ca certs) to validate the proxy's certificate. All getOrCreateHttpAgent call sites now pass TLS options when the proxy protocol is HTTPS. 3. Setting the `ca` option on any Node.js TLS connection replaces the default OpenSSL trust store entirely. CAs only in the OpenSSL default trust store (e.g. /etc/ssl/cert.pem) but not in tls.rootCertificates were lost. Fixed by converting `ca` to a secureContext via addCACert(), which appends custom CAs on top of the OpenSSL defaults instead of replacing them. Also simplified PatchedHttpsProxyAgent to selectively forward only the relevant TLS options (cert, key, pfx, passphrase, rejectUnauthorized, secureContext) to the target TLS upgrade instead of blindly merging all constructor options. * fix(tls): load client certs into secureContext to prevent silent drop Add Cache tab to Preferences UI * fix(proxy): align proxy auth check to use auth.disabled field consistently * refactor(cache): rename CLI flag to --cache-ssl-session and disable caching by default - Rename --disable-http-https-agents-cache to --cache-ssl-session (opt-in) - Rename disableHttpHttpsAgentsCache to cacheSslSession across CLI and bruno-requests - Default caching to disabled in both bruno-electron and bruno-cli - Add cacheSslSession to buildCertsAndProxyConfig for bru.sendRequest - Update Preferences UI labels to "Cache SSL Session" * refactor(cache): rename httpHttpsAgents to sslSession across preferences and UI * refactor(cache): remove unused getCacheStats and purgeCache IPC actions --------- Co-authored-by: karthik <47263234+kxbnb@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
0b7cd0e540 |
Revert "Performance/file parse and mount (#6975)" (#7360)
* Revert "Performance/file parse and mount (#6975)" This reverts commit |
||
|
|
f76f487211 |
Performance/file parse and mount (#6975)
* Refactor: optimize collection updates with batch processing - Introduced BatchAggregator to handle IPC events in batches, reducing Redux dispatch overhead during collection mounting. - Updated collection watcher to utilize batch processing for adding files and directories, improving UI performance. - Implemented ParsedFileCacheStore using LMDB for efficient caching of parsed file content, enhancing loading speed and reducing redundant parsing. - Adjusted collection slice to support batch addition of items, minimizing re-renders and improving state management. - Updated relevant components to reflect changes in loading states and collection data handling. * feat: add cache management to preferences - Introduced a new Cache component in the Preferences section to display cache statistics and allow users to purge the cache. - Implemented IPC handlers for fetching cache stats and purging the cache in the Electron main process. - Added styled components for better UI presentation of cache information. - Updated Preferences component to include a new tab for cache management. * fix: update package-lock.json to change 'devOptional' to 'dev' for several Babel dependencies * refactor: update batch aggregation parameters for improved performance - Increased DISPATCH_INTERVAL_MS from 150ms to 200ms for better timing control. - Adjusted MAX_BATCH_SIZE from 200 to 300 items to enhance batch processing efficiency. * feat: enhance collection loading state and improve batch aggregator functionality - Added isLoading property to collections slice to manage loading state during collection operations. - Updated getAggregator function calls in collection-watcher to include collectionUid for better context in batch processing. - Normalized directory path handling in parsed-file-cache to ensure consistent prefix creation for cache keys. * fix: update loading state and transient file handling in collections slice - Changed isLoading property to false during collection initialization for accurate loading state representation. - Introduced isTransient flag for directories and files to differentiate between transient and non-transient items. - Enhanced logic for handling transient directories and files during collection processing to improve state management. * feat: add batch processing support for file additions in task middleware - Implemented a new listener for collectionBatchAddItems to handle batch file additions. - Enhanced task management by checking for pending OPEN_REQUEST tasks that match added files. - Improved tab management by dispatching addTab actions for matching files and removing corresponding tasks from the queue. * feat: enable ASAR packaging and unpacking for LMDB binaries in Electron build configuration - Added ASAR support to the Electron build configuration for the Bruno application. - Specified unpacking rules for LMDB native binaries to ensure proper loading during runtime. * feat: implement parsed file cache using IndexedDB for improved performance - Introduced a new `parsedFileCacheStore` utilizing IndexedDB for caching parsed file data. - Replaced the previous LMDB-based cache implementation to enhance performance and reliability. - Updated IPC handlers to manage cache operations such as get, set, invalidate, and clear. - Integrated the new cache store into various components, ensuring efficient data retrieval and storage. - Added pruning functionality to remove outdated cache entries on startup. * refactor: update collection root and item handling to preserve UIDs - Modified the way collection roots and folder items are assigned by using `mergeRootWithPreservedUids` and `mergeRequestWithPreservedUids` to ensure UIDs are maintained during updates. - This change enhances data integrity when managing collections and their associated files. * refactor: pass mainWindow reference to parsedFileCacheStore initialization - Updated the `initialize` method in `ParsedFileCacheStore` to accept a `mainWindow` parameter, allowing for direct access to the main window instance in IPC handlers. - This change improves the handling of IPC requests by ensuring the correct window context is used for sending messages. * refactor: optimize getStats method in parsedFileCacheStore for performance - Replaced manual counting of total files with a direct count() call for O(1) performance. - Updated the collection counting logic to utilize openKeyCursor with 'nextunique' for improved efficiency in counting unique collection paths. - These changes enhance the performance of the getStats method by reducing the complexity of file and collection counting. * fix: update key generation in parsedFileCache to use newline separator - Changed the key generation logic in `generateKey` from a null character to a newline character for improved readability and consistency in cache keys. * refactor: rename batch-aggregator to collection-tree-batcher and add tests - Rename BatchAggregator class to CollectionTreeBatcher - Rename getAggregator/removeAggregator to getBatcher/removeBatcher - Update imports and variable names in collection-watcher.js - Add backward-compatible aliases for old names - Add 22 unit tests covering all functionality * refactor: update key generation in parsedFileCache to use custom separator - Changed the key generation logic in `generateKey` to use a custom separator (↝) instead of a newline character for improved readability and consistency in cache keys. * fix: add missing reject handler and fix directory prefix collision - Add reject to Promise and pendingRequests in parsed-file-cache-idb.js - Normalize dirPath with trailing separator in invalidateDirectory to prevent false matches (e.g., /foo/bar matching /foo/barley) - Use platform-specific path.sep for cross-platform compatibility * fix: add error handling in parsedFileCache and update window close event - Added a catch block to handle errors in the database promise in parsedFileCache. - Updated the window close event listener in collection-tree-batcher to use `once` for better resource management. * fix: add LRU eviction when IndexedDB quota is exceeded Handle QuotaExceededError in setEntry by automatically evicting the oldest 20% of cache entries and retrying the write operation. * fix: use once instead of on in mock window for batcher tests --------- Co-authored-by: Chirag Chandrashekhar <cchirag85@gmail.com> |