(related issue in cypress-file-upload)
https://github.com/abramenal/cypress-file-upload/issues/240
we tried to upgrade from 5.2.0 to 5.6.0 (along with starting to use route2), and we have error when trying to upload the image
works
cy.server().route('POST', '...').as('avatar');
has content-length mismatch, server responds with 422
cy.route2('POST', '...').as('avatar');
it.only('can upload avatar', () => {
cy.get('[data-qa="avatar-edit__input"]')
.attachFile('image/10kb-image.jpg')
// after attaching FE goes to `@avatar` route
.wait('@avatar')
.get('[data-qa="avatar-edit__container"]')
.should('have.css', 'background-image');
});
test image

5.6.0
I'm experiencing something similar with a regular JSON request. When the payload includes umlaute (รครผรถ) the json parser on the server cannot parse it, as part of the content at the end is missing. For every umlaut, there's one character in the body missing, e.g. {"key1": "รครครค", "key2": "def"} becomes {"key1": "รครครค", "key2": "de
According to the dev tools everything looks fine, but I assume route2 manipulates afterwards?
This happens as soon as route2 matches the url, and no modifications to request / response are necessary.
edit: However, it happens since 5.2.0 (and beyond), so maybe it's not the same root cause. Maybe @flotwig has time to take a look?
Took me an awful long time to find the problem ...
bug might have appeared in 5.4.0
in our case we have upgraded from 5.2.0 to 5.6.0
but we have not been using route2 at all (wanted to refactor all our requests to new API along with upgrade)
so there is a chance bug was there from the beginning
I'm experiencing something similar with a regular JSON request. When the payload includes umlaute (รครผรถ) the json parser on the server cannot parse it, as part of the content at the end is missing. For every umlaut, there's one character in the body missing, e.g.
{"key1": "รครครค", "key2": "def"}becomes{"key1": "รครครค", "key2": "deAccording to the dev tools everything looks fine, but I assume route2 manipulates afterwards?
This happens as soon as route2 matches the url, and no modifications to request / response are necessary.
edit: However, it happens since 5.2.0 (and beyond), so maybe it's not the same root cause. Maybe @flotwig has time to take a look?
Took me an awful long time to find the problem ...
Possibly this is due to this line:
It is incorrectly recalculating content-length for non-ASCII characters, so this should be using Buffer.from(str).byteLength instead.
Released in 6.0.0.
This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.0.0, please open a new issue.
Most helpful comment
Possibly this is due to this line:
https://github.com/cypress-io/cypress/blob/1c2a17560b704304bef4940aa924b2ad5373c50e/packages/net-stubbing/lib/server/intercept-request.ts#L267-L267
It is incorrectly recalculating content-length for non-ASCII characters, so this should be using
Buffer.from(str).byteLengthinstead.