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

Don't persist path error on startup for forever #14

Closed
StarpTech opened this issue Oct 25, 2017 · 6 comments
Closed

Don't persist path error on startup for forever #14

StarpTech opened this issue Oct 25, 2017 · 6 comments

Comments

@StarpTech
Copy link
Member

StarpTech commented Oct 25, 2017

When I initialize fastify-plugin in folder /static and the path does not exists 404 error is thrown. When I create the folder /static after that the error still persists and the user doesn't know what's going on. We don't have to persist that error the path is already checked by send module and can be handled by the error events.

btw: Isn't possible to use serve-static as middleware ?

@allevo
Copy link
Member

allevo commented Oct 25, 2017

If /static doesn't exist, the server start up fails. no?

@StarpTech
Copy link
Member Author

No

@allevo
Copy link
Member

allevo commented Oct 25, 2017

This is a bug.
But there's a test here

I've written a little example

'use strict'

const fastify = require('fastify')()
const path = require('path')

fastify.register(require('./index'), {
  root: path.join(__dirname, 'unexisting-folder')
})

fastify.listen(0, function (err) {
  console.log(err)
})

And this script prints

Error: ENOENT: no such file or directory, stat '/Users/allevo/repos/fastify-static/non-exist-folder'

Could you provide some context?

@allevo
Copy link
Member

allevo commented Oct 25, 2017

NB: with avvio v3 the registration callback has no needed.

'use strict'

const fastify = require('fastify')()
const path = require('path')

fastify.register(require('./index'), {
  root: path.join(__dirname, 'unexisting-folder')
}, err => {
  console.log(err ? 'error' : '0') // <---- prints 'error'
})

fastify.listen(0, function (err) {
  console.log(err) // <--- err is undefined!
})

@StarpTech
Copy link
Member Author

Look at example 3 in issue fastify/fastify#391

@StarpTech
Copy link
Member Author

Fixed in fastify 0.30.3

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

2 participants