Skip to content
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

stubbed response fails for some response data #1032

Closed
acthp opened this issue Dec 7, 2017 · 3 comments
Closed

stubbed response fails for some response data #1032

acthp opened this issue Dec 7, 2017 · 3 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@acthp
Copy link

acthp commented Dec 7, 2017

  • Operating System: osx 10.10
  • Cypress Version: 1.1.3
  • Browser Version: chrome 62

Is this a Feature or Bug?

bug

Current behavior:

stubbed response is delivered to application code with no response data, for some values of response data

Desired behavior:

stubbed response is delivered to application code with response data

How to reproduce:

Not sure what triggers this, but see the code, below. content is a large binary string. The request succeeds for some values of content, and fails for others. The difference might be the length (the failing cases are longer), or string content (the longer cases might have different bytes), or ??? The data is always correct here, in the call to cy.route().

The exception is ajax error 0, null response. I've been trying to trace the stub code, but haven't yet been able to understand how it works.

I see that the request is amended with X-Cypress-Response. I wasn't able to trace it past there, or work backward from the exception. It seems that things have already gone sour before the stack trace that leads to the exception (i.e. the response has been delivered as null, which triggers the stack trace that eventually throws on the null).

Test code:

cy.wait('@bookmark').then(xhr => {
	var content = decodeURIComponent(xhr.request.body.slice("content=".length));
	cy.route({
		url: '/api/bookmarks/bookmark*',
		method: 'GET',
		headers: {
			'content-type': 'binary/octet-stream',
			'content-length': content.length
		},
		response: content
	});
                                                                                                          
	cy.visit(heatmapPage.url + '?bookmark=1234', {onBeforeLoad: exec(clearSessionStorage, disableHelp)});
});
@acthp
Copy link
Author

acthp commented Dec 7, 2017

I found the proxy code in xhrs.js, and also noted the requests in the terminal log. In the failing case, the request is never logged, and adding more instrumentation in xhrs.js suggests the request is never making it to the server.

I have a suspicion that the browser or proxy has a header size limit.

Update:
If it is a header limit, a workaround might be to redirect to a data URI, but I haven't found a hook that allows manipulation of the routed xhr before it is opened.

@jennifer-shehane
Copy link
Member

@jennifer-shehane
Copy link
Member

Closing in favor of #76

@jennifer-shehane jennifer-shehane added the type: duplicate This issue or pull request already exists label Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants