Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* [#1271](https://github.com/mozilla/glean.js/pull/1271): BUGFIX: Fix pings validation function when scanning pings database on initialize.
* This bug was preventing pings that contained custom headers from being successfully validated and enqueued on initialize.
* [#1335](https://github.com/mozilla/glean.js/pull/1335): BUGFIX: Fix uploading gzip-compressed pings in Node.

# v1.0.0 (2022-03-17)

Expand Down
3 changes: 2 additions & 1 deletion glean/src/platform/node/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import https from "https";
import http from "http";

import { isString } from "../../core/utils.js";
import log, { LoggingLevel } from "../../core/log.js";
import Uploader, {
UploadResult,
Expand Down Expand Up @@ -55,7 +56,7 @@ class NodeUploader extends Uploader {
});

// Finish sending the request.
request.end(body);
request.end(isString(body) ? body : Buffer.from(body.buffer));
});
}
}
Expand Down
20 changes: 12 additions & 8 deletions glean/tests/unit/platform/node/uploader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ describe("Uploader/Node", function () {

it("returns the correct status for successful requests", async function () {
for (const status of [200, 400, 500]) {
nock(MOCK_ENDPOINT).post(/./i).reply(status);

const response = NodeUploader.post(MOCK_ENDPOINT, "");
const expectedResponse = new UploadResult(UploadResultStatus.Success, status);
assert.deepStrictEqual(
await response,
expectedResponse
);
// We support both plain text and binary payloads (for gzipped content)
// so test them both.
for (const body of ["", new Uint8Array()]) {
nock(MOCK_ENDPOINT).post(/./i).reply(status);

const response = NodeUploader.post(MOCK_ENDPOINT, body);
const expectedResponse = new UploadResult(UploadResultStatus.Success, status);
assert.deepStrictEqual(
await response,
expectedResponse
);
}
}
});

Expand Down