Loopback-next: AssertionError [ERR_ASSERTION]: The binding selector must be an address

Created on 5 Feb 2020  Β·  20Comments  Β·  Source: strongloop/loopback-next

I've just done an npm upgrade and cannot start or build.
Note this is an lb3-mounted app. I never could get any of the migration to succeed (as of the orig port to lb4).

Node: v12.14.1
@loopback/[email protected]

loopback-fukup

test-log.txt

$ npm ls @loopback/context
β”œβ”€β”¬ @loopback/[email protected]
β”‚ β”œβ”€β”€ @loopback/[email protected] 
β”‚ └─┬ @loopback/[email protected]
β”‚   └── @loopback/[email protected] 
β”œβ”€β”€ @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └─┬ @loopback/[email protected]
β”‚   └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
└─┬ @loopback/[email protected]
  └── @loopback/[email protected] 
$ lb4 update
The project dependencies are compatible with @loopback/[email protected]
IoContext bug

Most helpful comment

I can reproduce the problem now.

One workaround is to run npm dedup so that @loopback/context is only installed at root level.

All 20 comments

@CNSKnight, from your above screen cap, I realized that the @loopback/context has upgraded from 1.x to 2.x. Could you please take a look at how to deal with the breaking changes https://github.com/strongloop/loopback-next/blob/master/packages/context/CHANGELOG.md#200-2020-01-27?

Can you run npm ls @loopback/context to see if you have other versions of @loopback/context?

BTW, try to upgrade using lb4 update after installing the latest version of CLI with npm i -g @loopback/cli.

Am getting a build but start throws:

$ node .
Cannot start the application. AssertionError [ERR_ASSERTION]: The binding selector must be an address (string or BindingKey)
    at /var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolver.js:106:29
    at /var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolution-session.js:92:53
    at Object.tryWithFinally (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/value-promise.js:157:18)
    at Function.runWithInjection (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolution-session.js:92:32)
    at resolve (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolver.js:99:61)
    at /var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolver.js:176:16
    at Object.resolveList (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/value-promise.js:130:32)
    at resolveInjectedArguments (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolver.js:159:28)
    at Object.instantiateClass (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolver.js:43:27)
    at /var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/binding.js:433:46
    at Binding._getValue (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/binding.js:319:20)
    at /var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/binding.js:215:29
    at /var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolution-session.js:72:53
    at Object.tryWithFinally (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/value-promise.js:157:18)
    at Function.runWithBinding (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/resolution-session.js:72:32)
    at Binding.getValue (/var/www/loopback-projects/RecipesAPI-lb4/node_modules/@loopback/core/node_modules/@loopback/context/dist/binding.js:213:67) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

What did you see for npm ls @loopback/context? You might have two different versions in the tree.

In my case it is

─┬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
β”œβ”€β”€ @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └─┬ @loopback/[email protected]
β”‚   └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected] 
└─┬ @loopback/[email protected]
  └── @loopback/[email protected] 

The old version @loopback/[email protected] is causing the problem. Please run npm i @loopback/[email protected] to make sure all versions are the same.

@CNSKnight Please run rm -rf node_modules followed by npm i. Your stack trace shows there is an older version of @loopback/context is still inside @loopback/core/node_modules.

Having the same issue after updating the dependencies today. Already tried removing the node_modules and re-installing all dependencies. npm ls also shows only Version 2.1.0 of @loopback/context is installed in the project

Any update on this, it's broken my deployment.
Error: cannot start the application. { AssertionError [ERR_ASSERTION]: The binding selector must be an address (string or BindingKey)

+-- @loopback/[email protected]
| -- @loopback/[email protected] +-- @loopback/[email protected] +-- @loopback/[email protected] |-- @loopback/[email protected]
+-- @loopback/[email protected]
| -- @loopback/[email protected] |-- @loopback/[email protected]
+-- @loopback/[email protected]
| -- @loopback/[email protected] +-- @loopback/[email protected] |-- @loopback/[email protected]
-- @loopback/[email protected] -- @loopback/[email protected]

@baswag @rajanmishra Can you post the stack trace? If you have a simple project to reproduce the issue, please share.

What’s your node/npm version? On what OS?

{
    "error": {
        "generatedMessage": false,
        "code": "ERR_ASSERTION",
        "actual": false,
        "expected": true,
        "operator": "=="
    },
    "trace": [{
        "column": 29,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolver.js",
        "function": null,
        "line": 106,
        "method": null,
        "native": false
    }, {
        "column": 53,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolution-session.js",
        "function": null,
        "line": 92,
        "method": null,
        "native": false
    }, {
        "column": 18,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\value-promise.js",
        "function": "Object.tryWithFinally",
        "line": 157,
        "method": "tryWithFinally",
        "native": false
    }, {
        "column": 32,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolution-session.js",
        "function": "Function.runWithInjection",
        "line": 92,
        "method": "runWithInjection",
        "native": false
    }, {
        "column": 61,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolver.js",
        "function": "resolve",
        "line": 99,
        "method": null,
        "native": false
    }, {
        "column": 16,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolver.js",
        "function": null,
        "line": 176,
        "method": null,
        "native": false
    }, {
        "column": 32,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\value-promise.js",
        "function": "Object.resolveList",
        "line": 130,
        "method": "resolveList",
        "native": false
    }, {
        "column": 28,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolver.js",
        "function": "resolveInjectedArguments",
        "line": 159,
        "method": null,
        "native": false
    }, {
        "column": 27,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolver.js",
        "function": "Object.instantiateClass",
        "line": 43,
        "method": "instantiateClass",
        "native": false
    }, {
        "column": 46,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\binding.js",
        "function": null,
        "line": 433,
        "method": null,
        "native": false
    }, {
        "column": 20,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\binding.js",
        "function": "Binding._getValue",
        "line": 319,
        "method": "_getValue",
        "native": false
    }, {
        "column": 29,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\binding.js",
        "function": null,
        "line": 215,
        "method": null,
        "native": false
    }, {
        "column": 53,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolution-session.js",
        "function": null,
        "line": 72,
        "method": null,
        "native": false
    }, {
        "column": 18,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\value-promise.js",
        "function": "Object.tryWithFinally",
        "line": 157,
        "method": "tryWithFinally",
        "native": false
    }, {
        "column": 32,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\resolution-session.js",
        "function": "Function.runWithBinding",
        "line": 72,
        "method": "runWithBinding",
        "native": false
    }, {
        "column": 67,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\binding.js",
        "function": "Binding.getValue",
        "line": 213,
        "method": "getValue",
        "native": false
    }, {
        "column": 36,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\context.js",
        "function": "RequestContext.getValueOrPromise",
        "line": 491,
        "method": "getValueOrPromise",
        "native": false
    }, {
        "column": 21,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\context\\dist\\context.js",
        "function": "RequestContext.get",
        "line": 410,
        "method": "get",
        "native": false
    }, {
        "column": 47,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\rest\\dist\\http-handler.js",
        "function": "HttpHandler._handleRequest",
        "line": 39,
        "method": "_handleRequest",
        "native": false
    }, {
        "column": 49,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\rest\\dist\\http-handler.js",
        "function": "HttpHandler.handleRequest",
        "line": 15,
        "method": "handleRequest",
        "native": false
    }, {
        "column": 33,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\rest\\dist\\rest.server.js",
        "function": "RestServer._handleHttpRequest",
        "line": 218,
        "method": "_handleHttpRequest",
        "native": false
    }, {
        "column": 18,
        "file": "C:\\loopbackProject\\node_modules\\@loopback\\rest\\dist\\rest.server.js",
        "function": null,
        "line": 154,
        "method": null,
        "native": false
    }]
}

Node: 12.8.0
NPM: 6.13.4
@loopback/cli: 1.30.0
OS: Windows 7

`poj@poj-2 obo-nlp-server % lb4 update
The project was originally generated by @loopback/cli@.
The following dependencies are incompatible with @loopback/[email protected]:

  • @types/node: ^10.14.6 (cli ^10.17.14)
  • prettier: ^1.16.4 (cli ^1.19.1)
  • typescript: ^3.3.1 (cli ~3.7.5)
  • @loopback/authentication: ^1.0.17 (cli ^3.3.2)
  • @loopback/boot: ^1.0.12 (cli ^1.7.3)
  • @loopback/build: ^1.3.0 (cli ^3.1.1)
  • @loopback/core: ^1.1.6 (cli ^1.12.3)
  • @loopback/openapi-v3: ^1.2.1 (cli ^1.13.0)
  • @loopback/repository: ^1.1.5 (cli ^1.19.0)
  • @loopback/testlab: ^1.0.6 (cli ^1.10.3)
  • @loopback/service-proxy: ^1.0.8 (cli ^1.3.16)
  • @loopback/rest-explorer: ^1.1.8 (cli ^1.4.9)
    ` please help me T^T

We fixed this for our project by:

  • Deleting any yarn.lock and package-lock.json files you may have
  • Using the CLI to perform lb4 update

β”œβ”€β”¬ @loopback/[email protected]
β”‚ β”œβ”€β”€ @loopback/[email protected]
β”‚ └─┬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
β”œβ”€β”€ @loopback/[email protected]
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └─┬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
β”œβ”€β”¬ @loopback/[email protected]
β”‚ └── @loopback/[email protected]
└─┬ @loopback/[email protected]
└── @loopback/[email protected]

This is how my npm ls @loopback/context looks like now, but it still doesn't work
I have deleted the package-lock, node-modelus, and run a npm i with loockback/context version as 2.1.0.

@raimundoGarcia What OS do you have? What's your stacktrace?

I use ubuntu, and now seems to be working well >_>
Thanks :)

I can reproduce the problem now.

One workaround is to run npm dedup so that @loopback/context is only installed at root level.

Please upgrade to @loopback/[email protected]. The most reliable approach is as follows:

  1. npm i -g @loopback/cli
  2. Go to your project
  3. lb4 update
Was this page helpful?
0 / 5 - 0 ratings