Skip to content

feat!: remove child_process dependency for browser compatibility#968

Merged
intcreator merged 2 commits intokelektiv:v5from
WillianAgostini:feat/967
Apr 19, 2025
Merged

feat!: remove child_process dependency for browser compatibility#968
intcreator merged 2 commits intokelektiv:v5from
WillianAgostini:feat/967

Conversation

@WillianAgostini
Copy link
Copy Markdown
Contributor

@WillianAgostini WillianAgostini commented Feb 27, 2025

Description

BREAKING CHANGE: Removed the ability to execute system commands using string-based inputs. This eliminates the dependency on child_process, improving browser compatibility. Users relying on this functionality should migrate to executing commands manually within their own implementations.

Related Issue

#967

Motivation and Context

Running node-cron in a browser-based environment.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [ X ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ X ] My code follows the code style of this project.
  • [ X ] My change requires a change to the documentation.
  • [ X ] I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • [ X ] All new and existing tests passed.
  • [ X ] If my change introduces a breaking change, I have added a ! after the type/scope in the title (see the Conventional Commits standard).

BREAKING CHANGE: Removed the ability to execute system commands using string-based inputs.
This eliminates the dependency on `child_process`, improving browser compatibility.
Users relying on this functionality should migrate to executing commands manually within their own implementations.

kelektiv#967
@sheerlox sheerlox requested review from intcreator and sheerlox March 1, 2025 14:11
@intcreator
Copy link
Copy Markdown
Collaborator

just want to give an update on this, I'm holding off for now because this would require a major version change and we just released a major version. at the very least I would like to bundle one other breaking change I've been meaning to make for a v5 release, which is deprecating the arguments list constructor in favor of only using a single object argument constructor

@Faq
Copy link
Copy Markdown

Faq commented Apr 17, 2025

Can this be released as beta/alfa node module to test out?

Update:
This solves #538

@Elliot67
Copy link
Copy Markdown

@Faq It is very likely an issue on your end as this PR doesn't include any reference to child_process anymore.

@intcreator @sheerlox This PR is really needed to improve readability and usability of the project.

I just started using cron for the first time, and ran in the following issues :

  • using system command with a string is not documented
  • using system command with an object is not documented either
  • running an unknown system command doesn't trigger the errorHandler since the error can only be listened with childProcess.on('error', () => {})
  • running an unknown system command crash the parent process. If no .on('error') handler are registered on the childProcess, node will throw the error on the parent process, which would very likely crash an app 😢

@intcreator
Copy link
Copy Markdown
Collaborator

@Faq my goal is to release a beta version on a v5 branch today

@Elliot67 the reason this PR will fix the issue is because it will allow this library to be used in the browser, which is currently prevented by cron depending on Node.js functionality

my plan is to:

  1. move this change to a v5 branch
  2. release a beta version so people can at least us the beta version on the front end
  3. when we're ready to release v5, merge to the main branch and release as a major version change

while not explicitly documented, the functionality is mentioned in the documentation and it is intended functionality, so it merits a major version change in case people are relying on it working as is.

@intcreator intcreator changed the base branch from main to v5 April 19, 2025 21:28
@intcreator intcreator merged commit 525880f into kelektiv:v5 Apr 19, 2025
19 checks passed
@intcreator
Copy link
Copy Markdown
Collaborator

published to 5.0.0-beta.1: https://www.npmjs.com/package/cron/v/5.0.0-beta.1

I'll give it a couple of days for the testers to poke and then I should be ready to release a major v5 release

@intcreator
Copy link
Copy Markdown
Collaborator

53 downloads in the last few days. no complaints so far that I can see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants