[SOLVED] Aurelia 2, Kernel/Metadata not detecting metadata properly, bug?

using 0.6.0, So I’ve written this little “test”

const reflectKeys = Reflect.getMetadataKeys(OrderService).map( (k) => Reflect.getOwnMetadata(k, OrderService));
  let getOwnKeys = Metadata.getOwnKeys(OrderService).map((k) => Metadata.getOwn(k, OrderService));
  const dependencies = DI.getDependencies(OrderService);

  root.get<Logger>(LoggerDefault).info( 'Reflect %O Metadata %O Dependencies %O', reflectKeys, getOwnKeys, dependencies);
info:     Reflect [
    [Function: AmqpSender] { register: [Function: register] },
    [Function: Object] --- must be 'LoggerDefault`
] Metadata [
  [ <1 empty item>, 'LoggerDefault' ],
  [ 'au:annotation:di:paramtypes', 'au:annotation:di:dependencies' ]
] Dependencies [ <1 empty item>, 'LoggerDefault' ]

So here’s AmqpSender

export class AmqpSender implements Sender<any, void> {
    @inject(LoggerDefault) private readonly log: Logger,
    @inject(AmqpChannel) private readonly channel: Channel,
  ) {}

  async send(exchange: Exchange, message: AggregateEvent<any, any>): Promise<void> {
    this.log.silly('publishing to %s %j', exchange, message);
    if (!this.channel.publish(exchange, message.type, Buffer.from(JSON.stringify(message)))) {
      this.log.error('failed to publish %s %j', exchange, message);

and more importantly, what’s needed from OrderService

export class OrderService {
    private readonly sender: AmqpSender,
    @inject(LoggerDefault) private readonly log: Logger,
  ) {}

this is what’s in tsconfig

  "compilerOptions": {
    "outDir": "build",
    "target": "es2018",
    "module": "commonjs",
    "lib": [
    "moduleResolution": "node",
    "declaration": true,
    "strict": true,
    "esModuleInterop": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "resolveJsonModule": true
  "include": [
  "exclude": [
  "plugins": [
      "name": "@divyenduz/ts-graphql-plugin"

for the life of me I can’t figure out why Aurelia doesn’t see AmqpSender, when reflect-metadata can. Is this a bug?

udpate I checked nightly, it doesn’t appear to work there either

UPDATE decided a bug is appropriate because replacing the internally developed library with reflect-metadata fixed the issue. https://github.com/aurelia/aurelia/issues/833

1 Like