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.

Support for Feathers 5 with koa middleware

See original GitHub issue

Steps to reproduce

Create a new application with the Feathers 5 (currently 5.0.0-pre.31) generator and choose the defaults but specifically choose these -> (KOA) (JAVASCRIPT) Note: When I chose TypeScript, I couldn’t get past the typescript errors so I went back and used JavaScript.

npx @feathersjs/cli@pre generate app

Add feathers-distributed according to the documentation page: app.js

import feathersDistribution from '@kalisio/feathers-distributed'
...
app.configure(
  feathersDistribution({
    hooks: {
      before: {
        all: [
          // authenticate('jwt'),
        ]
      }
    },
    services: (service) => true,
    remoteServices: (service) => true
  })
)
export { app }

Then try to run the application with

npm run dev

Expected behavior

The application should run like it does with ExpressJS

Actual behavior

Application crashes with the following output:

> server@0.0.0 dev
> nodemon src/

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node src/`
warn: Publishing all events to all authenticated users. See `channels.js` and https://docs.feathersjs.com/api/channels.html for more information.
/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/service.js:55
        throw new Error(`Invalid service object passed for path \`${location}\``);
              ^

Error: Invalid service object passed for path `distribution/healthcheck/:key?`
    at wrapService (/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/service.js:55:15)
    at Feathers.use (/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/application.js:107:56)
    at Feathers.use (/home/user/code/feathers5-2/server/node_modules/@feathersjs/koa/lib/index.js:48:36)
    at Feathers.<anonymous> (file:///home/user/code/feathers5-2/server/node_modules/@kalisio/feathers-distributed/lib/index.js:385:9)
    at Feathers.configure (/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/application.js:37:18)
    at file:///home/user/code/feathers5-2/server/src/app.js:59:5
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
[nodemon] app crashed - waiting for file changes before starting...

I’ve debugged through the feathers-distributed code to the error points, but I don’t know how to fix them.

System configuration

Module versions (especially the part that’s not working): package.json

  "dependencies": {
    "@feathersjs/authentication": "^5.0.0-pre.31",
    "@feathersjs/authentication-local": "^5.0.0-pre.31",
    "@feathersjs/authentication-oauth": "^5.0.0-pre.31",
    "@feathersjs/configuration": "^5.0.0-pre.31",
    "@feathersjs/errors": "^5.0.0-pre.31",
    "@feathersjs/feathers": "^5.0.0-pre.31",
    "@feathersjs/koa": "^5.0.0-pre.31",
    "@feathersjs/mongodb": "^5.0.0-pre.31",
    "@feathersjs/schema": "^5.0.0-pre.31",
    "@feathersjs/socketio": "^5.0.0-pre.31",
    "@feathersjs/transport-commons": "^5.0.0-pre.31",
    "@feathersjs/typebox": "^5.0.0-pre.31",
    "@kalisio/feathers-distributed": "^2.0.2",
    "koa-static": "^5.0.0",
    "mongodb": "^4.11.0",
    "winston": "^3.8.2"
  },
  "devDependencies": {
    "@feathersjs/authentication-client": "^5.0.0-pre.31",
    "@feathersjs/cli": "^5.0.0-pre.31",
    "@feathersjs/rest-client": "^5.0.0-pre.31",
    "axios": "^0.27.2",
    "cross-env": "^7.0.3",
    "mocha": "^10.1.0",
    "nodemon": "^2.0.20",
    "prettier": "^2.7.1"
  }

NodeJS version: v16.15.1

NPM version: 8.11.0

Operating System: Ubuntu 22.04.1 LTS

Browser Version: n/a

React Native Version: n/a

Module Loader: n/a

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jchambcommented, Oct 24, 2022
0reactions
nathanbrizzee-cdcrcommented, Oct 28, 2022

Thanks so much @claustres . I tested the new healthcheck and it works great. I’ll try your suggestion for the errorHandler. I don’t know why I didn’t think of it but it makes sense the way you showed it. Guess I was thinking too hard. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Koa style middleware: Hooks for any asynchronous method
Hooks are a powerful way to control the flow of asynchronous methods. Koa popularized a new kind of middleware that allows an even...
Read more >
Koa | feathers
The @feathersjs/koa module contains the KoaJS framework integrations for Feathers. It will turn the Feathers app into a fully compatible KoaJS application.
Read more >
koajs/koa - Gitter
Already voiced my opinion on the Feathers issue tracker ... @jeffijoe trails supports koa but it exchanges one set of configuration for another....
Read more >
Koa - next generation web framework for node.js
You can quickly install a supported version of node with your favorite ... Koa middleware cascade in a more traditional way as you...
Read more >
Feathers the Node.js API framework you should consider
plugin API. One cool feature of Fastify that already sets it apart from Express/Koa for me is how the plugins or middleware can...
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