fastify / fastify-redis

Plugin to share a common Redis connection across Fastify.
MIT License
198 stars 31 forks source link

Unhandled async error with wrong Redis credentials #195

Closed Duaard closed 4 months ago

Duaard commented 5 months ago

Prerequisites

Fastify version

4.26.1

Plugin version

6.1.1

Node.js version

20.10.0

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

13.3

Description

As the title states, there's an unhandled async error when an invalid credentials are provided. This makes it hard to catch and display a custom error message.

Steps to Reproduce

  1. Create an empty fastify project
  2. Install the @fastify/redis package and register it.
  3. Make sure you have a running redis server.
  4. Configure the project with the right endpoint and wrong username/password.
  5. Server will crash with an unhandled async error that can't be wrapped in try...catch during plug in registration.

Expected Behavior

Async errors are handled and propagated through the plugin registration.

mcollina commented 5 months ago

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

Duaard commented 5 months ago

Hi @mcollina thanks for response, here I created a test repo: https://github.com/Duaard/unhandled-async-error

Steps to run:

mcollina commented 4 months ago

https://github.com/fastify/fastify-redis/pull/196 should fix.