diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..3f2eb16 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,5 @@ +# Agent Instructions + +## Versioning + +Don't change the `version` in `package.json` in a PR that makes other changes. Version bumps go in their own separate PR. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/package.json b/package.json index 0da7b31..0048b8d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "adm-zip": "^0.5.2", - "axios": "1.15.0", + "axios": "1.20.0", "chalk": "^4.1.0", "form-data": "^3.0.0", "glob": "^7.1.6", diff --git a/src/sourcemaps/signed-url-uploader.js b/src/sourcemaps/signed-url-uploader.js index 6113587..dd047d0 100644 --- a/src/sourcemaps/signed-url-uploader.js +++ b/src/sourcemaps/signed-url-uploader.js @@ -63,6 +63,10 @@ class SignedUrlUploader { headers: { 'Content-Type': 'application/octet-stream', }, + // maxBodyLength: don't cap the upload size client side; the signed URL + // decides what it accepts. maxContentLength (response size) matches RollbarAPI. + maxContentLength: Infinity, + maxBodyLength: Infinity, }); if (resp.status === 200) { output.status('Success', 'Uploaded zip file successfully'); diff --git a/test/sourcemaps/signed-url-uploader.test.js b/test/sourcemaps/signed-url-uploader.test.js index 7ab8f84..3278303 100644 --- a/test/sourcemaps/signed-url-uploader.test.js +++ b/test/sourcemaps/signed-url-uploader.test.js @@ -5,6 +5,7 @@ const expect = require('chai').expect; const sinon = require('sinon'); const axios = require('axios') +const http = require('http'); const SignedUrlUploader = require('../../src/sourcemaps/signed-url-uploader'); const Scanner = require('../../src/sourcemaps/scanner'); @@ -68,7 +69,35 @@ describe('.upload()', function() { statusText: 'Success', }); - await signedUrlUploader.upload(false, files); - expect(stub.callCount).to.equal(1); + try { + await signedUrlUploader.upload(false, files); + expect(stub.callCount).to.equal(1); + } finally { + stub.restore(); + } + }); + + it('should upload zips larger than 10 MB', async function() { + let received = 0; + const server = http.createServer((req, res) => { + req.on('data', (chunk) => { received += chunk.length; }); + req.on('end', () => { res.writeHead(200); res.end(); }); + }); + await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)); + + const size = 11 * 1024 * 1024; + const signedUrlUploader = new SignedUrlUploader(); + signedUrlUploader.zipFiles = function() { this.zipBuffer = Buffer.alloc(size); }; + const spy = sinon.spy(axios, 'put'); + + try { + await signedUrlUploader.upload(false, [], `http://127.0.0.1:${server.address().port}/`); + } finally { + spy.restore(); + server.close(); + } + + expect(spy.firstCall.args[2].maxBodyLength).to.equal(Infinity); + expect(received).to.equal(size); }); });