Repository navigation
fix: improve gzip creation function - #4389
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
This pull request refactors the Refactoring for Asynchronous Behavior:
Updates to Destination-Specific Network Handlers:
Test Case Adjustments:
Other Updates:
|
|
Allure Test reports for this run are available at:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## hotfix/11june2025 #4389 +/- ##
====================================================
Coverage ? 91.10%
====================================================
Files ? 637
Lines ? 33420
Branches ? 7891
====================================================
Hits ? 30448
Misses ? 2733
Partials ? 239 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| new Promise((resolve, reject) => { | ||
| gzip(payload, (err, dataCompress) => { | ||
| if (err) { | ||
| reject(err); |
There was a problem hiding this comment.
| const { networkHandler } = networkHandlerFactory.getNetworkHandler(destination, version); | ||
|
|
||
| const proxyDestReqPayload = networkHandler.prepareProxy(routerDeliveryPayload); | ||
| const proxyDestReqPayload = await networkHandler.prepareProxy(routerDeliveryPayload); |
There was a problem hiding this comment.
No one is using these routes, I think we can safely ignore the test coverage.
Made this change for the sake of completeness
| }; | ||
| const getZippedPayload = (payload) => | ||
| new Promise((resolve, reject) => { | ||
| gzip(payload, (err, dataCompress) => { |
There was a problem hiding this comment.
rename dataCompress to zippedPayload / compressedPayload
|
Allure Test reports for this run are available at:
|
|
|
https://replit.com/join/nsbgfsxyzn-dilipkola @maheshkutty check this: const zlib = require('zlib');
const { promisify } = require('util');
const gzip = promisify(zlib.gzip);
const gunzip = promisify(zlib.gunzip);
async function compressAndDecompress(input) {
try {
// Compress
const compressed = await gzip(input);
console.log('Compressed Buffer:', compressed);
// Decompress
const decompressed = await gunzip(compressed);
console.log('Decompressed String:', decompressed.toString());
// Verify
if (input === decompressed.toString()) {
console.log('✅ Success: Original and decompressed data match.');
} else {
console.log('❌ Error: Data mismatch.');
}
} catch (err) {
console.error('❌ Error during compression/decompression:', err);
}
}
// Test the function
const testString = 'Hello, this is a test string to be compressed using gzip!';
compressAndDecompress(testString); |



What are the changes introduced in this PR?
This pull request refactors the
prepareProxyRequestfunction across multiple files to make it asynchronous and replaces the synchronousgzipSyncmethod with the asynchronousgzipmethod for payload compression. It also updates related test cases to support asynchronous behavior and adjusts error handling for GZIP compression failures.Refactoring for Asynchronous Behavior:
src/adapters/network.js: RefactoredprepareProxyRequestandgetZippedPayloadto be asynchronous, usinggzipfor compression instead ofgzipSync. Updated related calls to useawait. [1] [2] [3] [4] [5]Updates to Destination-Specific Network Handlers:
src/v0/destinations/intercom/networkHandler.js: MadeprepareIntercomProxyRequestandintercomProxyRequestasynchronous. [1] [2]src/v0/destinations/pardot/networkHandler.js: RefactoredprepareProxyReqandpardotProxyRequestto be asynchronous. [1] [2]src/v0/destinations/rakuten/networkHandler.js: UpdatedprepareProxyRequestandproxyRequestto use asynchronous behavior.src/v0/destinations/snapchat_custom_audience/networkHandler.js: MadeprepareProxyReqandscAudienceProxyRequestasynchronous. [1] [2]src/v0/destinations/the_trade_desk/networkHandler.js: UpdatedproxyRequestto use asynchronousprepareProxyRequest.Test Case Adjustments:
src/adapters/network.test.js: Updated tests forprepareProxyRequestto handle asynchronous behavior and added specific tests for GZIP payload handling, including error scenarios. [1] [2] [3] [4]test/integrations/destinations/mp/dataDelivery/proxyV1.ts: Adjusted expected error messages for GZIP compression failures to align with the new asynchronous implementation.Other Updates:
src/services/delivertTest/deliveryTest.ts: MadeprepareProxycall asynchronous in theDeliveryTestService.What is the related Linear task?
Resolves INT-3639
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.