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

nosql causes exceptions in Node.js > v10.0.0 #14

Closed
bochap opened this issue Oct 7, 2018 · 8 comments
Closed

nosql causes exceptions in Node.js > v10.0.0 #14

bochap opened this issue Oct 7, 2018 · 8 comments

Comments

@bochap
Copy link

bochap commented Oct 7, 2018

nosql will cause an exception in FileReader.prototype.open line 2388 will cause an exception in Node.js > v10.0.0. The callback parameter is no longer optional for fs.close. Not passing it will throw a TypeError at runtime. There was a depreciation warning since Node.js v7.0.0. My workaround for now is to change fs.close to fs.closeSync in line 2388 of the index.js file in node_modules/nosql. The author has indeicated that he will be making changes to the module soon. Refer to petersirka/nosql#46

@ken5scal
Copy link

I am having the same issue with Node.js v10.12.0.

@mathiasconradt
Copy link

mathiasconradt commented Dec 4, 2018

Yes, had the same. Downgraded to 8.0.0 - or "nvm use 8.0", then it worked for me. Didn't try 10.x.

Related #18 (comment)

I doubt the code will be fixed for newer node versions unless a new edition of the book is planned.

@jricher
Copy link
Contributor

jricher commented Dec 7, 2018

This code was originally written on a very old version of Node.js. Looks like we might need to run through and update the internal dependencies, thanks for the pointers and confirmations.

@dmark
Copy link

dmark commented Feb 17, 2019

9.2.0 seems to work as well.

@dsnkostic
Copy link

If you do not want to change the node version, here is what you can do

  • First you need to update nosql library to the most recent one (6.1.0 seems to be working properly).
    Here is how package.json should look like:
{
  "dependencies": {
    "express": "^4.13.1",
    "sync-request": "^2.0.1",
    "body-parser": "^1.13.2",
    "underscore": "^1.8.3",
    "underscore.string": "^3.1.1",
    "consolidate": "^0.13.1",
    "qs": "^4.0.0",
    "randomstring": "^1.0.7",
    "nosql": "^6.1.0",
    "cors": "^2.7.1"
  }
}

Don't forget to execute npm update in the folder of the package.json

  • Go in protectedResource.js and update method that is causing the error to this one:
nosql.one().make(function(builder) {
  builder.where('access_token', inToken);
  builder.callback(function(err, response) {
    console.log(response);
    if (response) {
      console.log("We found a matching token: %s", inToken);
    } else {
      console.log('No matching token was found.');
    };
    req.access_token = response;
    next();
    return;
  })
});

This should fix the issue.

Author should update and retest all of the exercises as this issue makes oAuth2 In Action book unusable at the very beginning (unless you want to downgrade your nodejs)

artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik pushed a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik pushed a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik pushed a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 11, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 12, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 14, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 14, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 15, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 16, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 16, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 17, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 17, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 22, 2019
artursudnik added a commit to artursudnik/oauth-in-action-code that referenced this issue Oct 25, 2019
@simongrigorian
Copy link

I would install NVM, and install node 8 -- this would fix the deprecated issue.

Babagilo pushed a commit to Babagilo/oauth-in-action-code that referenced this issue May 25, 2020
@timmi4sa
Copy link

timmi4sa commented Oct 6, 2020

If you do not want to change the node version, here is what you can do

  • First you need to update nosql library to the most recent one (6.1.0 seems to be working properly).
    Here is how package.json should look like:
{
  "dependencies": {
    "express": "^4.13.1",
    "sync-request": "^2.0.1",
    "body-parser": "^1.13.2",
    "underscore": "^1.8.3",
    "underscore.string": "^3.1.1",
    "consolidate": "^0.13.1",
    "qs": "^4.0.0",
    "randomstring": "^1.0.7",
    "nosql": "^6.1.0",
    "cors": "^2.7.1"
  }
}

Don't forget to execute npm update in the folder of the package.json

  • Go in protectedResource.js and update method that is causing the error to this one:
nosql.one().make(function(builder) {
  builder.where('access_token', inToken);
  builder.callback(function(err, response) {
    console.log(response);
    if (response) {
      console.log("We found a matching token: %s", inToken);
    } else {
      console.log('No matching token was found.');
    };
    req.access_token = response;
    next();
    return;
  })
});

This should fix the issue.

Author should update and retest all of the exercises as this issue makes oAuth2 In Action book unusable at the very beginning (unless you want to downgrade your nodejs)

Is it me or the authorizationServer.js file also requires a conversion from "nosql.all()" to "nosql.all().make(..)"? Otherwise I am getting the same error once updated the "nosql" module to version 6.1.0.

@jricher
Copy link
Contributor

jricher commented Oct 13, 2020

Should be fixed by #44

@jricher jricher closed this as completed Oct 13, 2020
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

No branches or pull requests

8 participants