Skip to content

Custom plugins aren't available in onBegin/onEnd #910

Description

@MathieuLoutre

Hello there! I'm using @delucis' bgio-effects and I'm trying to access it inside a phase's onEnd hook but it comes out as undefined while ctx.random is there alongside the other default plugins.

@delucis created a reproduction after a short chat.

I did a bit more digging writing some failing tests and discovered that there seems to be link with the flush of the plugins. Plugins without flush are available and if a plugin has a flush it's not. I'm not too familiar with the structure of boardgame.io so I mostly dug around with some console logs to track it down.

When this part of the code executes, pluginState contains all the right things, but only the data gets written which removes the API that the plugin provides and thereafter the relevant plugin in state.plugins is just an empty data object.

I'm happy to provide a PR/fix but I'm not too sure what is supposed to happen. Would adding back the rest of the state like here be a simple fix that doesn't disturb anything else?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions