question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Not implemented. Use bindAsync() instead

See original GitHub issue

Problem description

Code throws error: Error: Not implemented. Use bindAsync() instead at: server.bind(127.0.0.1:${PORT}, ServerCredentials.createInsecure())

throw new Error(‘Not implemented. Use bindAsync() instead’); ^

Error: Not implemented. Use bindAsync() instead at Server.bind (/home/sales/MEGAsync/projects/pc-command-grpc/server/node_modules/.pnpm/@grpc+grpc-js@1.6.7/node_modules/@grpc/grpc-js/build/src/server.js:200:15) at main (/home/sales/MEGAsync/projects/pc-command-grpc/server/dist/main.js:30:12) at Object.<anonymous> (/home/sales/MEGAsync/projects/pc-command-grpc/server/dist/main.js:34:1) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions…js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47

Reproduction steps

main.ts code:

`import { loadPackageDefinition, Server, ServerCredentials } from "@grpc/grpc-js"
import { loadSync, Options } from "@grpc/proto-loader"
import "dotenv/config"
import { join } from "path"
import { ProtoGrpcType as CommandGrpcType } from "./proto/command"
import { CommandServiceHandlers } from "./proto/command/CommandService"

if (!process.env.PORT) {
  throw new Error("PORT not set!")
}
if (!process.env.PC_MAC_ADDRESS) {
  throw new Error("PC_MAC_ADDRESS not set!")
}

const { PORT } = process.env

const commandProtoPath = join(__dirname, "..", "proto", "command.proto")

const loaderOptions: Options = {
  keepCase: true,
  longs: String,
  enums: String,
  defaults: true,
  oneofs: true
}

const commandProtoDefinition = loadSync(commandProtoPath, loaderOptions)

const commandPackageDefinition = loadPackageDefinition(
  commandProtoDefinition
) as unknown as CommandGrpcType

const commandServiceHandlers: CommandServiceHandlers = {
  TurnOn() {}
}

async function main() {
  const server = new Server()
  server.addService(
    commandPackageDefinition.command.CommandService.service,
    commandServiceHandlers
  )

  server.bind(`127.0.0.1:${PORT}`, ServerCredentials.createInsecure())
  server.start()

  console.log(`listening on port ${PORT}...`)
}
main()`

Environment

Linux Ubuntu 22.04 amd64 Node v16.15.0 Node installation method - nvm @grpc/grpc-js@1.6.7

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
nicolasnoblecommented, Jun 2, 2022

That’s because it’s Not implemented, and you should Use bindAsync() instead.

0reactions
nicolasnoblecommented, Jun 2, 2022

https://github.com/grpc/grpc-node/tree/master/packages/grpc-js#migrating-from-grpc is basically documenting the differences from the legacy package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

grpc.Server.bindAsync JavaScript and Node.js code examples
How to use. bindAsync. function. in. Server. Best JavaScript code snippets using grpc.Server.
Read more >
How do you to implement a GRPC server in TypeScript?
You can use the proto-loader to generate types. First, install the proto-loader: npm i @grpc/proto-loader. You can then generate the types like ...
Read more >
@grpc/grpc-js - npm
gRPC Library for Node - pure JS implementation. ... you are using Server#bind to bind ports, you will need to use Server#bindAsync instead....
Read more >
Documentation Class: Server - gRPC on GitHub
addProtoService. Add a proto service to the server, with a corresponding implementation. Deprecated: Use grpc.Server#addService instead ...
Read more >
Tutorial: How to Build Your First Node.js gRPC API - Trend Micro
gRPC uses HTTP/2, which is faster than HTTP/1 used by other ... While not mandatory, JavaScript knowledge is also quite helpful.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found