Skip to content

some tweaks to handling 304 Not Modified responses - #3421

Merged
joshaber merged 13 commits into
masterfrom
correlate-request-ids-in-log
Nov 28, 2017
Merged

joshaber merged 13 commits into
masterfrom
correlate-request-ids-in-log

Conversation

@shiftkey

@shiftkey shiftkey commented Nov 27, 2017 •

Copy link
Copy Markdown
Member

Fixes #3399

  • for fetchAll, if we've got a suspicious 304 let's log it and return an empty array instead
  • make mentionables endpoint a bit more robust, unclear on root cause there
  • the error handling in deserialize<T> doesn't stringify correctly - let's only look at some of the fields we're interested in when deserializing content

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 27, 2017
@shiftkey shiftkey removed the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 27, 2017
@shiftkey shiftkey changed the title HTTP 304 might not have a cached response some tweaks to handling 304 Not Modified responses Nov 27, 2017
@shiftkey

Copy link
Copy Markdown
Member Author

Looking at the original error log again, it seems like these are the two code paths that aren't being handled correctly:

2017-11-21T17:45:27.478Z - warn: [ui] Unable to deserialize JSON string to object [object Response]
SyntaxError: Unexpected token � in JSON at position 0
2017-11-21T17:45:27.479Z - warn: [ui] fetchPullRequests: failed for repository wheatvivo/datasources
SyntaxError: Unexpected token � in JSON at position 0
2017-11-21T17:45:27.480Z - warn: [ui] Error refreshing pull requests for 'datasources'
SyntaxError: Unexpected token � in JSON at position 0

This one can be traced back to fetchAll not expecting a 304. Although we don't set If-None-Match for this endpoint there's screenshots in #3399 that suggests the server can still trigger this.

I believe this is the error that's being displayed to the user in #3399, which will be handled better now.

2017-11-21T17:45:27.493Z - warn: [ui] Unable to deserialize JSON string to object [object Response]
TypeError: Failed to fetch
2017-11-21T17:45:27.495Z - warn: [ui] fetchMentionables: failed for wheatvivo/datasources
TypeError: Failed to fetch

This one is even more puzzling. Aside from storing an empty string instead of null in 37c3f88 and seeing if a different status code ends up in deserialize<T> in 872e944 I think this one needs more monitoring.

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 27, 2017
@joshaber joshaber self-assigned this Nov 27, 2017

@joshaber joshaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question around logging.

Comment thread app/src/lib/api.ts Outdated
log.warn(`fetchAll: '${path}' returned a 404`)

if (response.status === HttpStatusCode.NotModified) {
log.warn(`fetchMentionables: '${path}' returned a 304`)

This comment was marked as spam.

This comment was marked as spam.

@shiftkey

Copy link
Copy Markdown
Member Author

🍎

@joshaber
joshaber merged commit cd67215 into master Nov 28, 2017
@joshaber
joshaber deleted the correlate-request-ids-in-log branch November 28, 2017 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants