Skip to content

A custom plugin's init and hook methods are invoked twice during make #3452

Open

Description

@cwellsx

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.2.0

Electron version

28.1.0

Operating system

Windows 10

Last known working Electron Forge version

6.0.0

Expected behavior

I have a custom plugin named ResourcePlugin -- https://github.com/cwellsx/electron-forge-resource-plugin
It's configured in forge.config.ts like this -- https://github.com/cwellsx/electron_forge_template/blob/dotnet/forge.config.ts

When I run electron-forge make then I expect its init function and its hook functions to be called once.

I observed this expected behaviour when I used 6.0.0 of Electron Forge.

Actual behavior

With v7.2.0 I see the init function and the hook functions (not the constructor) being called twice.
The plugin therefore edits the extraResource property twice -- which causes a failure.
Below is a debug log file also including log messages from my ResourcePlugin

C:\Users\Christopher\Source\Repos\electron_forge_template>npm run make

> [email protected] make
> set DEBUG=electron-forge&& electron-forge make

√ Checking your system
[STARTED] Loading configuration
ResourcePlugin: constructor
ResourcePlugin: init(C:\Users\Christopher\Source\Repos\electron_forge_template)
ResourcePlugin: getHooks()
ResourcePlugin: resolveForgeConfig
ResourcePlugin: setting extraResource=C:\Users\CHRIST~1\AppData\Local\Temp\electron-forge-resource-plugin\core
ResourcePlugin: addDefine - Added to Webpack configuration: {"CORE_EXE":"\"resources\\\\core\\\\Core.exe\""}
[SUCCESS] Loading configuration
[STARTED] Resolving make targets
[DATA] Making for the following targets:
[SUCCESS] Resolving make targets
[STARTED] Running package command
[STARTED] Preparing to package application
ResourcePlugin: init(C:\Users\Christopher\Source\Repos\electron_forge_template)
ResourcePlugin: resolveForgeConfig
ResourcePlugin: setting extraResource=C:\Users\CHRIST~1\AppData\Local\Temp\electron-forge-resource-plugin\core,C:\Users\CHRIST~1\AppData\Local\Temp\electron-forge-resource-plugin\core
ResourcePlugin: addDefine - Added to Webpack configuration: {"CORE_EXE":"\"resources\\\\core\\\\Core.exe\""}
[SUCCESS] Preparing to package application
[STARTED] Running packaging hooks
... etc ...

I'll edit the plugin to correct this -- i.e. to not edit the property twice -- but this bug report is FYI in case your running a plugin's methods twice isn't what you wanted to be doing -- I don't think that you documented this as new or breaking behaviour in the release notes, nor as expected behaviour in https://www.electronforge.io/advanced/extending-electron-forge/writing-plugins

Steps to reproduce

Additional information

No response

Activity

  1. added
    make
    and removed on Jan 31, 2025
  2. added this to the 8.0.0 milestone on Feb 1, 2025
  3. added a commit that references this issue on Sep 17, 2026
    2412039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcustom-addonsmake

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions