Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

@service(GeocoderProvider) Fails with "No Binding Found" in LoopBack Component

Abierto
#11,062 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
typescript
Área
backend

Línea de trabajo

Comienza en la application.ts del ejemplo todo y sigue el registro de Service Booter hasta @service y filterByServiceInterface. Lee la ruta de createServiceBinding y el comportamiento propuesto de los metadatos de @serviceOptions; después, reproduce el fallo con la rama bug-no-binding-found y GET /todo. Se considera terminado cuando el GeocoderProvider sobrescrito se resuelve mediante @service sin un error No binding found.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Describe the bug

Problem Description
@service(GeocoderProvider) Fails with "No Binding Found" in LoopBack Component after overriding the same class via Service booter in application.

❓ Problem Statement
You created a custom LoopBack Component named DummyComponent, which declares and registers models, repositories, controllers, and a service (GeocoderProvider):

export class DummyComponent implements Component {
  ...
  services?: ServiceOrProviderClass[];
  ...
  constructor(
    @inject(CoreBindings.APPLICATION_INSTANCE)
    private application: Application,
  ) {
    this.services = [GeocoderProvider]; // <-- Intended to register the service
  }
}

and used in a controller as

export class TodoController {
  constructor(
    @repository(TodoRepository)
    public todoRepository: TodoRepository,
    
    @service(GeocoderProvider) // <-- This fails
    protected geoService: Geocoder,
  ) {}
}

i added DummyComponent in application.ts as

this.component(DummyComponent);

this works fine. but when i override the GeocoderProvider via Service Booter.
this gives me error

500 Error: No binding found for GeocoderProvider. 
Make sure a service binding is created in context RequestContext-xxxx with serviceInterface (GeocoderProvider).

Steps to reproduce:

Reason for this error->
@service decorator filters the binding based on a functions

export function filterByServiceInterface(
  serviceInterface: ServiceInterface,
): BindingFilter {
  return binding =>
    binding.valueConstructor === serviceInterface ||
    binding.tagMap[CoreTags.SERVICE_INTERFACE] === serviceInterface;
}

and if we explicitly does not provide interface then it uses class itself as interface and used it for comparison. and we end up with two different services that causes comparison to fail and returning no binding found.
As we don't have any options to provide this interface(serviceOptions) via service booter. either we need to Manually bind services after the boot process (defeating the purpose of convention-based discovery)

Solution:
I have created a decorator @serviceOptions decorator that allows you to annotate service classes with configuration options metadata. It uses the factory pattern to create decorators with a specific options metadata key.
Then createServiceBinding function is the core registration mechanism that:

  • Extracts metadata: Retrieves decorator-defined options from the class
  • Merges configurations: Combines decorator metadata with manually passed options (manual options take precedence)
  • and rest will be same
Logs

Additional information

No response

Reproduction

https://github.com/Tyagi-Sunny/loopback-next/tree/bug-no-binding-found

Lenguaje dominante
TypeScript
Estrellas
5.1k
Forks
1.1k
Merge medio
4 d 4 h
PR fusionados (30 d)
44

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de loopbackio/loopback-next

Todos los issues de loopbackio/loopback-next

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.