-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throw when there's no boundary #122
Conversation
Latest bench: { cpu: { brand: 'M1', speed: '2.4 GHz' } }
| Node | Option | Msecs/op | Ops/sec | V8 |
| ------- | -------------- | -------------- | -------- | --------------------- |
| 20.5.0 | fastify-busboy | 0.113441 msecs | 8815.123 | V8 11.3.244.8-node.10 |
| 20.5.0 | busboy | 0.206708 msecs | 4837.743 | V8 11.3.244.8-node.10 |
| 16.13.0 | fastify-busboy | 0.270984 msecs | 3690.248 | V8 9.4.146.19-node.13 |
| 16.13.0 | busboy | 0.340114 msecs | 2940.190 | V8 9.4.146.19-node.13 |
| 12.22.7 | busboy | 1.945927 msecs | 513.894 | V8 7.8.279.23-node.56 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final remark
It seems that the unit tests dont fail in any case. If bufferStartsWith always returns false or always returns true, npm test runs pass always. |
They pass because if the function returns // types-multipart.spec.js
{
source: [
' ------WebKitFormBoundaryTB2MiQ36fnSJlrhY--\r\n'
],
boundary: '----WebKitFormBoundaryTB2MiQ36fnSJlrhY',
expected: [],
shouldError: 'Unexpected end of multipart data',
what: 'empty form with preceding whitespace'
},
{
source: [
'------WebKitFormBoundaryTB2MiQ36fnSJlrhY--\r\n'
],
boundary: '----WebKitFormBoundaryTB2MiQ36fnSJlrhYY',
expected: [],
shouldError: 'Unexpected end of multipart data',
what: 'empty form with wrong boundary (extra Y)'
},
{
source: [
''
],
boundary: '----WebKitFormBoundaryTB2MiQ36fnSJlrhY',
expected: [],
shouldError: 'Unexpected end of multipart data',
what: 'No fields and no files'
}, |
The test should not pass if it is intended to fail. I am currently working on #123 to replace mocha/chai with tap. Maybe first transform to tap? |
No test is better than having a test that never fails. ;) |
Hmm, this one should fail if the function always returns false though but it doesn't – it used to a few commits ago: {
source: [
'------WebKitFormBoundaryTB2MiQ36fnSJlrhY--\r\n'
],
boundary: '----WebKitFormBoundaryTB2MiQ36fnSJlrhY',
expected: [],
what: 'empty form'
}, |
#123 can be reviewed. Have a look please |
Hey, @Uzlopak, could you please see the latest commit, it simply calls end on dicer and lets it handle the input Tests seem to all pass nicely, let me know if something doesn't add up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain further, what the issue was?
There was a lot of duplication going on as Dicer also handles validation, but we would skip it by directly emitting finish when ‘nparts’ was 0 I haven’t benchmarked which approach is faster but dicer has already finished parsing the input by the time we reach the end and throws when the boundary does not exist So I couldn’t be sure if adding all that code was necessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@kibertoad |
marking as semver-major, as it changes the behaviour significantly. |
This PR fixes #121
Checklist
npm run test
andnpm run benchmark
and the Code of conduct