Skip to content

Handle doc lookup where id not found, and remove problematic hash-to-query addon #592

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

Merged

Conversation

toddjordan
Copy link
Contributor

@toddjordan toddjordan commented Feb 7, 2019

Addresses #589

This defect does a couple of things to potentially help out some of the high heroku memory usage and load we've been seeing.

  1. Removes the failed fetch of undefined.json we've been seeing over and over again in the logs.
06 Feb 2019 22:02:35.181104 <190>1 2019-02-07T03:02:34.860227+00:00 app web.1 - - message:
06 Feb 2019 22:02:35.181271 <190>1 2019-02-07T03:02:34.860229+00:00 app web.1 - - 'invalid json response body at https://ember-api-docs.global.ssl.fastly.net/json-docs/ember/3.7.3/namespaces/undefined.json reason: Unexpected token < in JSON at position 0',
06 Feb 2019 22:02:35.181118 <190>1 2019-02-07T03:02:34.860231+00:00 app web.1 - - type: 'invalid-json' }
06 Feb 2019 22:02:36.696498 <158>1 2019-02-07T03:02:36.572532+00:00 heroku router - - at=info method=GET path="/ember/release/namespaces/Ember/methods/_warnIfUsingStrippedFeatureFlags?anchor=_warnIfUsingStrippedFeatureFlags&show=inherited,protected,private,deprecated" host=ember-api-docs.herokuapp.com request_id=7b35a561-fd4c-4b1a-80d3-b8fd94ccf806 fwd="144.76.2.149, 54.145.171.140, 157.52.99.46,157.52.79.29" dyno=web.1 connect=2ms service=2360ms status=307 bytes=342 protocol=https
06 Feb 2019 22:02:36.861282 <190>1 2019-02-07T03:02:36.571712+00:00 app web.1 - - 2019-02-07T03:02:36.571Z 307 OK /ember/release/namespaces/Ember/methods/_warnIfUsingStrippedFeatureFlags?anchor=_warnIfUsingStrippedFeatureFlags&show=inherited,protected,private,deprecated
06 Feb 2019 22:02:36.862279 <190>1 2019-02-07T03:02:36.742249+00:00 app web.1 - - { FetchError: invalid json response body at https://ember-api-docs.global.ssl.fastly.net/json-docs/ember/3.7.3/namespaces/undefined.json reason: Unexpected token < in JSON at position 0
    at /app/tmp/deploy-dist/node_modules/node-fetch/lib/index.js:247:32
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
06 Feb 2019 22:02:36.936104 <190>1 2019-02-07T03:02:36.742257+00:00 app web.1 - - message:
06 Feb 2019 22:02:36.936271 <190>1 2019-02-07T03:02:36.742258+00:00 app web.1 - - 'invalid json response body at https://ember-api-docs.global.ssl.fastly.net/json-docs/ember/3.7.3/namespaces/undefined.json reason: Unexpected token < in JSON at position 0',
06 Feb 2019 22:02:36.936178 <190>1 2019-02-07T03:02:36.742260+00:00 app web.1 - - type: 'invalid-json' } 'fetching by class or module failed, retrying as namespace'
06 Feb 2019 22:02:36.936279 <190>1 2019-02-07T03:02:36.804212+00:00 app web.1 - - { FetchError: invalid json response body at https://ember-api-docs.global.ssl.fastly.net/json-docs/ember/3.7.3/namespaces/undefined.json reason: Unexpected token < in JSON at position 0
    at /app/tmp/deploy-dist/node_modules/node-fetch/lib/index.js:247:32
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
  1. Removes the hash-to-query internal addon, which adds a script to index.html that performs a reload of the url to fetch a method or property defined after the hash in the url of a legacy link. This approach has shown to be unreliable and often results in the errors above, as well as multiple requests made to the server (and decreased user experience). For the time being, we'll only support legacy urls at the class/namespace/package level and not at the method/property/event level. The user will still be taken to the right page, but they'll have to find the function onscreen.

@toddjordan
Copy link
Contributor Author

The findRecord function in the adapter is wicked complex. I'd like to add some testing around it, but I think this fix can proceed without it. I've create #593 to add adapter tests.

@locks locks temporarily deployed to ead-review-app-pr-592 February 7, 2019 06:21 Inactive
let encodedRevId = encodeURIComponent(revId);
url = `json-docs/${projectName}/${version}/${pluralize(modelNameToUse)}/${encodedRevId}`;
} else {
throw new Error('Documentation item not found');
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this just trading a "cannot access blah of undefined" error with a "Documentation item not found" error?

My experience with the issue of thrown errors causing potential memory leaks is that any kind of error will cause it 🤔 Would we be able to console.log() this message and then just return null or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we catch the error in the calling route model function, and then handle it. My assumption was that it was the uncaught error that was causing it, which was happening because we were letting the error happen deep in the nodejs fetch code as opposed to here.

Copy link
Member

Choose a reason for hiding this comment

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

that sounds legit to me 🎉 😂 I wasn't actually sure if you handled the error anywhere or if it ended up being "unhandled" from Ember's perspective

Copy link
Member

@mansona mansona left a comment

Choose a reason for hiding this comment

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

looks good to me 👍

@toddjordan
Copy link
Contributor Author

I plan to do some extra memory heap analysis before deploying this change using some tips from tom: ember-fastboot/fastboot#100 (comment)

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

Successfully merging this pull request may close these issues.

3 participants