klaascuvelier/alfred-mdn

RefferenceError: results is not defined on v2.0.2

Closed this issue · 14 comments

Hi, I've just updated alfred-mdn to check if it's working after #6 fixin and got this error:

[11:38:57.374] Logging Started...
[11:39:06.348] mdn[Script Filter] Queuing argument 's'
[11:39:06.657] mdn[Script Filter] Queuing argument 'sl'
[11:39:06.857] mdn[Script Filter] Queuing argument 'sli'
[11:39:06.961] mdn[Script Filter] Queuing argument 'slic'
[11:39:07.049] mdn[Script Filter] Queuing argument 'slice'
[11:39:08.381] mdn[Script Filter] Script with argv 'slice' finished
[11:39:08.384] ERROR: mdn[Script Filter] Code 1: {
"items": [
{
"title": "ReferenceError: results is not defined\n at alfy.fetch.then.results (/Users/evanre/.nvm/versions/node/v10.13.0/lib/node_modules/alfred-mdn/index.js:9:23)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
"valid": false,
"text": {
"copy": "\nReferenceError: results is not defined\n at alfy.fetch.then.results (/Users/evanre/.nvm/versions/node/v10.13.0/lib/node_modules/alfred-mdn/index.js:9:23)\n\n\n-\nmdn 2.0.2\nAlfred 4.0.3\ndarwin 18.7.0",
"largetype": "ReferenceError: results is not defined\n at alfy.fetch.then.results (/Users/evanre/.nvm/versions/node/v10.13.0/lib/node_modules/alfred-mdn/index.js:9:23)"
},
"icon": {
"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
}
}
]
}

Alright, I'll have a look at this.I can add some hardening in the results call.
Can you consistently reproduce this? Is there a specific search you did?

I currently am not able to reproduce.

Hi Klaas I have the same problem with all searches:

ReferenceError: results is not defined
    at /Users/peter/.nvm/versions/node/v12.4.0/lib/node_modules/alfred-mdn/index.js:9:23

@peterschussheim @evanre how do you install the plugin?

I just did a removal + reinstall and still works for me:

➜  ~ npm uninstall -g alfred-mdn

> alfred-mdn@2.0.2 preuninstall /Users/klaas/.nvm/versions/node/v10.16.0/lib/node_modules/alfred-mdn
> alfy-cleanup

removed 225 packages in 1.66s
➜  ~ npm install -g alfred-mdn

> alfred-mdn@2.0.2 postinstall /Users/klaas/.nvm/versions/node/v10.16.0/lib/node_modules/alfred-mdn
> alfy-init

+ alfred-mdn@2.0.2
added 222 packages from 80 contributors and updated 3 packages in 11.905s

@klaascuvelier:

I uninstalled the previous version and installed the latest exactly as you did. Did that 3 times today just to be sure.

@klaascuvelier I only typed npm install -g alfred-mdn in the terminal and 2.0.2 version has installed. The version is also changed in the WorkFlow's settings. Here is npm list output:

npm list -g --depth 0
/Users/evanre/.nvm/versions/node/v10.13.0/lib
├── alfred-mdn@2.0.2

Can you consistently reproduce this?

Yes, it repeats on any query.

Strange, but after I've tried to debug it (I just put console log in .then() callback) after few attempts it started to work. I have no idea what the problem was but it seems to me that the MDN API is buggy and can sometimes return a wrong response.

still not working on my machine

I'll reopen this one, as there's still people with the same issue>

I just published 2.0.3 which adds a check on results so it will not throw an error, but of course this does not solve the underlying problem.

For people still experiencing issues, can you perhaps debug the transform function on the bottom of index.js file and see what's happening there?

@klaascuvelier
2.0.3 seems to have solved the issue for me:
image

Weird, perhaps callback gets called multiple times? First time the results aren't available, 2nd time they are. So before with the incomplete/empty result code broke and 2nd call did not happen.
Just guessing here.
@peterschussheim @evanre does 2.0.3 work for all of you?

@klaascuvelier 2.0.3 works. Thank you, I appreciate the time you put into fixing this promptly.

Published another version with the changes of the MDN endpoint.
Hope this still works for all of you.

If @evanre also has no problems anymore, then we can close this ticket :)

@klaascuvelier It works great. Thank you for your extension!