Skip to content

Undefined services causes exception #1757

@marcus-pousette

Description

@marcus-pousette
  • Version:
    0.45.0

Severity:

Low

Description:

Creating a libp2p instance with services that are undefined creates a null pointer exception even if it is allowed by the types

createLibp2p({
...,
    services: {
         abc: undefined
    }
})

To mitigate this I think there needs to be a null check before this

const service: any = createService(this.components)

to check if createService is a function.

I ended up with this error because I am generating different configs based on conditions, and this leads me to assign "undefined" to services relay occasionally

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugA bug in existing code (including security flaws)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions