Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bedrock/core

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bedrock/core - npm Package Compare versions

Comparing version 6.2.0 to 6.3.0

14

CHANGELOG.md
# `@bedrock/core` ChangeLog
## 6.3.0 - 2024-11-19
### Added
- Add `bedrock.shutdown()` call that performs an orderly shutdown and emits
various events. This differs from `exit()` and `process.exit()` which are
more immediate.
- Add `bedrock.stopped` event, emitted before `bedrock.exit`.
- Add documentation for `bedrock.stop`, `bedrock.stopped`, and `bedrock.exit`
events.
### Changed
- Deprecate undocumented `bedrock-cli.exit` event. Use `bedrock.exit` instead.
If there is use case for this specific event, please file an issue.
## 6.2.0 - 2024-10-15

@@ -4,0 +18,0 @@

35

lib/index.js

@@ -95,3 +95,3 @@ /*!

* @returns {Promise} Resolves when the application has started or an error has
* occured.
* occurred.
*/

@@ -238,5 +238,5 @@ export async function start(options = {}) {

/**
* Called from a worker to exit gracefully and without an error code. Typically
* used by subcommands. Use `process.exit(1)` (or other error code) to exit
* with an error code.
* Called from a worker to exit immediately and without an error code.
* Typically used by subcommands. Use `process.exit(1)` (or other error code)
* to exit with an error code. Use `shutdown` to perform an orderly exit.
*/

@@ -247,2 +247,12 @@ export function exit() {

/**
* Called from a worker to exit gracefully and without an error code. Typically
* used by subcommands. Use `process.exit(1)` (or other error code) to exit
* with an error code. Use `exit()` to exit immediately. This call will emit
* events for an orderly shutdown.
*/
export async function shutdown() {
await _exit();
}
async function _waitForOneMessage({type, id}) {

@@ -726,3 +736,3 @@ // get coordinated message from primary

async function _exit(code) {
async function _exit(code = 0) {
/* Notes on exiting:

@@ -761,2 +771,4 @@

}
await events.emit('bedrock.stopped');
// FIXME: deprecated in v6.x, remove in v7+
await events.emit('bedrock-cli.exit');

@@ -766,4 +778,8 @@ await events.emit('bedrock.exit');

} finally {
await _logExit(code);
process.exit(code);
if(cluster.isPrimary) {
await _logExit(code);
process.exit(code);
} else {
cluster.worker.kill();
}
}

@@ -779,6 +795,3 @@ }

async function _logExit(code = 0) {
if(!cluster.isPrimary) {
return;
}
async function _logExit(code) {
// log final message and wait for logger to flush

@@ -785,0 +798,0 @@ const logger = loggers.get('app').child('bedrock/primary');

{
"name": "@bedrock/core",
"version": "6.2.0",
"version": "6.3.0",
"type": "module",

@@ -5,0 +5,0 @@ "description": "A core foundation for rich Web applications.",

@@ -579,8 +579,9 @@ # Bedrock® _(@bedrock/core)_

- **bedrock-cli.init**
- Emitted before command line parsing. Allows registration of new subcommands.
- Emitted before command line parsing. Allows registration of new
subcommands.
- **bedrock-cli.parsed**
- Emitted after command line parsing. Allows for configuration of loggers
based on command line flags. For instance, a logger may provide for the
specification of a `logGroupName` that may be computed at runtime based
on some command line flag(s).
specification of a `logGroupName` that may be computed at runtime based on
some command line flag(s).
- **bedrock-loggers.init**

@@ -592,3 +593,4 @@ - Emitted after command line parsing. Allows registration of new logging

execution of subcommands or the prevention of `bedrock` events from being
emitted, either by canceling this event or by exiting the application early.
emitted, either by canceling this event or by exiting the application
early.
- **bedrock.configure**

@@ -610,6 +612,6 @@ - Emitted after `bedrock-cli.ready` and before `bedrock.admin.init`. Allows

privileges are dropped. Allows listeners to perform early initialization
tasks that do not require special privileges. This event should be used
to ensure, for example, that a module's API has the required supporting
data structures in memory prior to another module's use of it. For example,
a validation module may need to load validation schemas from files on disk
tasks that do not require special privileges. This event should be used to
ensure, for example, that a module's API has the required supporting data
structures in memory prior to another module's use of it. For example, a
validation module may need to load validation schemas from files on disk
before they can be accessed via its API, but this loading must occur after

@@ -619,5 +621,5 @@ the configuration events have passed and after special process privileges

events during `bedrock.init` because it may cause scenarios where two
unrelated modules can't be easily combined.** For example, if a module emits
a custom event during `bedrock.init`, then a listener of that event would
be unable to use the API of an unrelated module that hasn't been
unrelated modules can't be easily combined.** For example, if a module
emits a custom event during `bedrock.init`, then a listener of that event
would be unable to use the API of an unrelated module that hasn't been
initialized yet. Deferring custom event emitting to `bedrock.start` solves

@@ -649,2 +651,13 @@ this problem; it ensures all modules have had a chance to complete

using a property matching their framework name.
- **bedrock.stop**
- Emitted while exiting if process was previous in a started state. This is
the event modules should use to stop services for a clean shutdown and to
emit any custom events they would like to make available to their
dependents.
- **bedrock.stopped**
- Emitted while exiting, and after `bedrock.stop` if process was previously
in a started state. External access to web services or other features
provided by modules should now be unavailable.
- **bedrock.exit**
- Emitted immediately before exiting.

@@ -651,0 +664,0 @@ ### bedrock.loggers

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc