`nock.recorder.rec` does not record when stream not put into flowing mode
See original GitHub issueWhat is the expected behavior?
nock.recorder.play()
should contain the recorded version of the request to GetObject.
What is the actual behavior?
Request does not appear in array returned from nock.recorder.play()
.
How to reproduce the issue
const nock = require('nock');
const { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3');
const s3 = new S3Client();
const bucket = '';
const key = '';
async function main() {
nock.recorder.rec({ dont_print: true });
try {
await s3.send(new GetObjectCommand({ Bucket: bucket, Key: 'invalid' }));
} catch { }
const response = await s3.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
console.log(response.Body.statusCode);
console.log(nock.recorder.play());
}
main()
.then(() => process.exit(0))
.catch((err) => {
console.log(err);
process.exit(1);
})
Fill in bucket
and key
and run. key
must be a valid and present S3 key.
With a valid bucket
and key
the output is:
200
[
'\n' +
`nock('https://test-onelivex.s3.us-east-2.amazonaws.com:443', {"encodedQueryParams":true})\n` +
" .get('/invalid')\n" +
' .query({"x-id":"GetObject"})\n' +
' .reply(404, "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>invalid</Key><RequestId>6XB4DKCEPRQPWWY0</RequestId><HostId>pHwvM3hwyAKmDqYq6z6uBRIFos+UhBwM9hMAdOBbuTSXUaM3seP1yTV0C93o3RKE152McDWBnvE=</HostId></Error>", [\n' +
" 'x-amz-request-id',\n" +
" '6XB4DKCEPRQPWWY0',\n" +
" 'x-amz-id-2',\n" +
" 'pHwvM3hwyAKmDqYq6z6uBRIFos+UhBwM9hMAdOBbuTSXUaM3seP1yTV0C93o3RKE152McDWBnvE=',\n" +
" 'Content-Type',\n" +
" 'application/xml',\n" +
" 'Transfer-Encoding',\n" +
" 'chunked',\n" +
" 'Date',\n" +
" 'Mon, 19 Apr 2021 00:48:04 GMT',\n" +
" 'Server',\n" +
" 'AmazonS3'\n" +
']);'
]
Versions
Software | Version(s) |
---|---|
Nock | 0.21.1 |
@aws-sdk/client-s3 | 3.13.0 |
Node | v15.12.0 |
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Why did Nock not record all the api requests? | BytesMatter
We ran into an issue where Nock wasn't recording api calls to a new service dependency we introduced into the BytesMatter codebase.
Read more >nockBack fails to record any fixtures - node.js - Stack Overflow
I do set the back.fixtures option. There is no recording in the fixtures directory and none is created without the nock.restore() call. With...
Read more >Nock: HTTP Mocking and Expectations - Morioh
Nock. HTTP server mocking and expectations library for Node.js. Nock can be used to test modules that perform HTTP requests in isolation.
Read more >GPU - River Thames Conditions
Length of texas coastline, Big name no blanket abc, Nuoto milano master? ... Art 809 rv, Qysh me qel add skype, Top selling...
Read more >Nock - JavaScripting.com
If no request headers are specified for mocking then Nock will automatically skip matching of request headers. Since the host header is a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi! Just wagering a guess that this is not a problem with nock. I’d guess an invalid bucket and key is erroring out in the AWS SDK before the HTTP request is made. Maybe you can catch the exception and see.
Okay, #2257 has been created.