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

Custom stream protocols will sometimes give empty or partial responses (Electron 4) #16213

Closed
pfrazee opened this issue Dec 29, 2018 · 6 comments

Comments

@pfrazee
Copy link
Contributor

pfrazee commented Dec 29, 2018

  • Output of node_modules/.bin/electron --version: 4.0.0
  • Operating System (Platform and Version): MacOS 10.12
  • Output of node_modules/.bin/electron --version on last known working Electron version (if applicable): 3.0.9

Expected Behavior

Custom stream protocol responses should consistently provide the full response body of the request.

Actual behavior

Custom stream protocol responses will occasionally give an empty or partial response.

In both cases, the headers are present in devtools. When an empty response is given, the response body is missing.

When a partial response is given, the total size is consistently 4 bytes less than the sum of some of the chunks. For instance, if there are two chunks of 100b then 50b, the received size might be 96b (4b less than the first chunk's size). If there are three chunks of 100b, then 50b, then 25b, the received size might be 96b (4b less than the first chunk) or it might be 146b (4b less than the first two chunks combined). I mention this because the 4b pattern is consistent, and might give a clue about the cause.

I have been unable to reliably reproduce the issue, making me think this is simply a race within the stream-protocol code.

Things which did not seem to affect the behavior:

  • Sandboxing
  • Caching
  • Webview vs running within the browser window
  • Any of the security settings or optional behavior flags on BrowserWindow/WebView
  • The presence of preload scripts
  • The size of the response
  • The timing if the response
  • Which resource was requested (it varies)

To Reproduce

# Clone this repository
git clone https://github.com/pfrazee/electron-bug-test-truncated-protocol-responses
# Go into the repository
cd electron-bug-test-truncated-protocol-responses
# Install dependencies
npm install
# Run the app
npm start

Then:

  • The window will open with README.md rendered and devtools open. Switch to the network tab so that you can log requests.
  • Typically the request will succeed. Refresh repeatedly (cmd/ctrl + r) until the window becomes blank.
  • Notice in the network tab, the request response is empty, though the headers are set.
@KoenLav
Copy link
Contributor

KoenLav commented Jan 6, 2019

We seem to be experiencing the same problem when making use of meteor-desktop; pretty consistently the main asset of our application will be a few bytes short of complete.

@burtonator
Copy link

This is a pretty severe regression on 4.0... a main API should not simply stop working and it shouldn't take weeks to resolve.

Is this API not tested? How did the 4.0 release even happen?

It makes it hard to commit to Electron when major platform APIs simply don't work.

@KoenLav
Copy link
Contributor

KoenLav commented Jan 13, 2019

By the way; we are running on Windows and the issue seems the same, so I don't think this is platform specific.

@jkleinsc
Copy link
Contributor

jkleinsc commented Jan 28, 2019

Fixed via #16532/#16540

@pfrazee
Copy link
Contributor Author

pfrazee commented Jan 28, 2019

Awesome, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants