Skip to content

Commit 4d5a43d

Browse files
author
unclespode
committed
Fix: Cannot read property 'headers' of undefined
Occasionally, you will get "Cannot read property 'headers' of undefined" when trying to request a header. It's randomly crashing my daemon - I assume when I get a null response from a server. This does a couple of extra checks.
1 parent a8a8074 commit 4d5a43d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/XMLHttpRequest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ exports.XMLHttpRequest = function() {
205205
this.getResponseHeader = function(header) {
206206
if (typeof header === "string"
207207
&& this.readyState > this.OPENED
208+
&& response
209+
&& response.headers
208210
&& response.headers[header.toLowerCase()]
209211
&& !errorFlag
210212
) {

0 commit comments

Comments
 (0)