Lock: Uncaught TypeError: req.setNoDelay is not a function

Created on 10 Nov 2017  路  40Comments  路  Source: auth0/lock

I've tried to add Auth0Lock...

Only one line of code:

 this.lock = new Auth0Lock(my_id, my_domain)

and got this in console...What I did wrong?!

auth0-lock: ^10.24.0
node: v8.8.1
React: 16.1.0
Brouser: Chrome 61.0.3163.79
OS: Linux 4.10.0-38-generic 42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

2017-11-10 12-04-47

Most helpful comment

Yeah. We have incompatible versions of a dependency. Please use the CDN until we migrate to the latest dependency of superagent.

All 40 comments

Can you show me your dependencies list? Maybe it's an incompatible dependency? Neither Lock or auth0-js call setNoDelay, so I'm guessing you have a conflicting version?

I did some test.
Now I have [email protected] installed. And I have error Uncaught TypeError: req.setNoDelay is not a function when I try to call lock.getUserInfo(authResult.accessToken, (error, profile) => {...}

When I added */10.21.1/lock.min.js version, instead of using npm package, everything works.
Is it possible what something wrong with auth0-lock package??

From my package.json:

"dependencies": {
    "auth0-js": "^8.11.2",
    "auth0-lock": "^10.24.1",
    "babel-runtime": "^6.26.0",
    "bootstrap": "^3.3.7",
    "history": "^4.7.2",
    "lodash": "^4.17.4",
    "meteor-node-stubs": "^0.3.2",
    "react": "^16.1.1",
    "react-bootstrap": "^0.31.5",
    "react-dom": "^16.1.1",
    "react-redux": "^5.0.6",
    "react-router-dom": "^4.2.2",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0",
    "underscore": "^1.8.3"
},

I've tried 11.0.0-beta.3 without any luck. But */10.24.1/lock.min.js works like a charm. No problem at all.
Looks like problem with auth0-lock or some of his deps.

OK, looks like superagent: '^3.3.1' is a problem.
Only in superagent:

// set tcp no delay
req.setNoDelay(true);

superagent is in auth0-lock dependencies

Although it's wrongly listed as a dependency, the v11 beta doesn't use superagent at all. v10 uses it, though. The issue is still unclear to me. Can you build a repro project so I can test it?

I created this test: https://github.com/n0ne/Meteor-Auth0

If uncomment line in client/main.html and comment first in client/services/authenticationService.js - working fine. In other case - nope...

Can you create a simple sample without meteor? I want to take everything out of the table so we can focus only on Lock.

I need some more time for research... create-react-app bare project working. Bare Meteor project - nope.
Looks like not the Lock problem...

I think meteor adds superagent as well and it has a different version. That's why bundling auth0-lock in your project doesn't work but using the cdn makes it work. Remove auth0-lock from your project, install the dependencies again and see if there's a superagent there.

What dependencies I have to install? I can create new bare project...

remove auth0-lock from your test project, run npm install and see if there's a superagent there..

I'm closing this one because it's a compat issue with meteor. You'll have to use the CDN for this one.

Actually, the setNoDelay thing was added in 3.6.0 (https://github.com/visionmedia/superagent/releases/tag/v3.6.0). If you use yarn, you can add a resolution and set your desired version for superagent. I think that if you add superagent as a dependency of your project, it will work as a workaround as well.

OK. I created new bare meteor project - no superagent. Added auth0-lock - many-many superagents (-: Mostly in auth0-js and auth0-lock. And in yarn.lock for auth0-lock exist [email protected], not only superagent@^3.3.1...
Removed auth0-lock - no superagent....

Added only 2 packages to new bare project: first - superagent and second - auth0-lock...

2017-11-21 09-47-52

You mean a bare meteor project, right?

Yes. In bare meteor project no superagent... only after adding one package - auth0-lock

can you put here the commands to install the meteor cli, create a new project etc? I'll try this on my machine.

Thank you! (-:

  1. curl https://install.meteor.com/ | sh
  2. meteor create --bare test-project
  3. cd test-project
  4. meteor npm install
  5. meteor npm install --save auth0-lock

I'm really appreciate for your help...

Any ideas?

I get this issue as well.

Simply adding code from README

var clientId = 'xx';
var domain = 'xx.auth0.com';
var lock = new Auth0Lock(clientId, domain);

lock.on("authenticated", function(authResult) {
  lock.getUserInfo(authResult.accessToken, function(error, profile) {
    if (error) {
      // Handle error
      return;
    }

    localStorage.setItem("accessToken", authResult.accessToken);
    localStorage.setItem("profile", JSON.stringify(profile));

    // Update DOM
  });
});

triggers this error:

TypeError: req.setNoDelay is not a function[Learn More] modules.js:48361:3
    index.js/Request.prototype.request http://localhost:3000/packages/modules.js:48361:3
    index.js/Request.prototype.end http://localhost:3000/packages/modules.js:48488:3
    request-builder.js/RequestObj.prototype.end http://localhost:3000/packages/modules.js:44611:18
    index.js/Authentication.prototype.getSSOData http://localhost:3000/packages/modules.js:44138:10
    getSSOData http://localhost:3000/packages/modules.js:6943:13
    getSSOData http://localhost:3000/packages/modules.js:6709:13
    data.js/cache< http://localhost:3000/packages/modules.js:7613:10
    fetch http://localhost:3000/packages/modules.js:1824:5
    get http://localhost:3000/packages/modules.js:1818:5
    fetchSSOData http://localhost:3000/packages/modules.js:7617:3
    syncFn http://localhost:3000/packages/modules.js:7333:15
    process/< http://localhost:3000/packages/modules.js:8301:7
    reduce self-hosted:368:27
    process http://localhost:3000/packages/modules.js:8296:10
    updateEntity/< http://localhost:3000/packages/modules.js:1385:12
    updateInDeepMap http://localhost:3000/packages/modules.js:15913:22
    updateInDeepMap http://localhost:3000/packages/modules.js:15922:23
    updateInDeepMap http://localhost:3000/packages/modules.js:15922:23
    immutable.js/</Map.prototype.updateIn http://localhost:3000/packages/modules.js:15220:26
    updateEntity http://localhost:3000/packages/modules.js:1384:10
    swap http://localhost:3000/packages/modules.js:1472:25
    swap http://localhost:3000/packages/modules.js:1376:10
    go/</< http://localhost:3000/packages/modules.js:8339:15

do you also use meteor?

Yes its a Meteor app. It appears to be related to the bundled file sent to the client.

removing

import Auth0Lock from 'auth0-lock';

and including the lock code from the cdn works

<script src="http://cdn.auth0.com/js/lock/11.0.0-beta.3/lock.min.js"></script>

Yeah. We have incompatible versions of a dependency. Please use the CDN until we migrate to the latest dependency of superagent.

I'll be waiting ((-:

Doesn't work with new versions 10.24.2 and 11.0.0.
)))-:

@n0ne sorry, we got caught up with the new major releases and we needed to make sure to change as little as possible. I'll release patch releases with this migration shortly!

I also have this issue with Auth0 v9.0.2 when the DBConnection.changePassword method is called.

_Edit: just noticed this is the Auth0 Lock repository so this might not be the correct place to file this issue, sorry_

I made an issue in the Superagent repo too but they don't think it's related to Superagent: https://github.com/visionmedia/superagent/issues/1331

@pieterbeulque are you also using meteor?

No, it's in an Angular setup.

But in your lock-file still exists [email protected].......

I moved superagent to a dev dependency and updated auth0.js (which has an updated version of superagent). This should be enough. Can you test with the new version?

Hey @luisrudge, I'm running these versions and it is still happening for me. It only happens when calling the changePassword method, all other functionality works perfectly fine.

auth0-js@^9.1.0
auth0/angular-auth0@^3.0.0
[email protected]

@pieterbeulque are you server rendering your app? I'm running out of ideas. Can you build a simple repro project so I can test this?

It's in a client-side app, no server-side rendering whatsoever. If I log req before the req.setNoDelay call I get this structure:

module.exports = {
  body: [],
  uri: "https://{{ username }}.auth0.com:443/dbconnections/change_password",
  writable: true,
  xhr: XMLHttpRequest,
  _headers: {},
  __proto__ : Stream
}

Can you please build a simple repro so I can test this?

Alright, I dove a little bit (much) deeper and it's because we build the project with JSPM.

JSPM includes some stuff that allows require('http') to resolve to this http-browserify package.

That package doesn't have the setNoDelay method.

This is probably not an issue with Superagent / Auth0 then!

@n0ne @purplecones do you also use jspm?

Everything OK now!
Thank you very much! (-:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamtay picture adamtay  路  8Comments

sedubois picture sedubois  路  4Comments

virgil-av picture virgil-av  路  5Comments

fernandomunizz89 picture fernandomunizz89  路  3Comments

martsie picture martsie  路  5Comments