Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v22.5.1 proposal #53935

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V22.md#22.5.0">22.5.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V22.md#22.5.1">22.5.1</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V22.md#22.5.0">22.5.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V22.md#22.4.1">22.4.1</a><br/>
<a href="doc/changelogs/CHANGELOG_V22.md#22.4.0">22.4.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V22.md#22.3.0">22.3.0</a><br/>
Expand Down
17 changes: 17 additions & 0 deletions doc/changelogs/CHANGELOG_V22.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</tr>
<tr>
<td>
<a href="#22.5.1">22.5.1</a><br/>
<a href="#22.5.0">22.5.0</a><br/>
<a href="#22.4.1">22.4.1</a><br/>
<a href="#22.4.0">22.4.0</a><br/>
Expand Down Expand Up @@ -43,6 +44,22 @@
* [io.js](CHANGELOG_IOJS.md)
* [Archive](CHANGELOG_ARCHIVE.md)

<a id="22.5.1"></a>

## 2024-07-19, Version 22.5.1 (Current), @richardlau

### Notable Changes

This release fixes a regression introduced in Node.js 22.5.0. The problem is known to display the following symptoms:

* Crash with `FATAL ERROR: v8::Object::GetCreationContextChecked No creation context available` [#53902](https://github.com/nodejs/node/issues/53902)
* npm errors with `npm error Exit handler never called!` [npm/cli#7657](https://github.com/npm/cli/issues/7657)
* yarn hangs or outputs `Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)` [yarnpkg/berry#6398](https://github.com/yarnpkg/berry/issues/6398)

### Commits

* \[[`e2deeedc6e`](https://github.com/nodejs/node/commit/e2deeedc6e)] - _**Revert**_ "**fs**: add v8 fast api to closeSync" (Aviv Keller) [#53904](https://github.com/nodejs/node/pull/53904)

<a id="22.5.0"></a>

## 2024-07-16, Version 22.5.0 (Current), @RafaelGSS prepared by @aduh95
Expand Down
17 changes: 3 additions & 14 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1841,23 +1841,12 @@ void Environment::AddUnmanagedFd(int fd) {
}
}

void Environment::RemoveUnmanagedFd(int fd, bool schedule_native_immediate) {
void Environment::RemoveUnmanagedFd(int fd) {
if (!tracks_unmanaged_fds()) return;
size_t removed_count = unmanaged_fds_.erase(fd);
if (removed_count == 0) {
if (schedule_native_immediate) {
SetImmediateThreadsafe([&](Environment* env) {
ProcessEmitWarning(this,
"File descriptor %d closed but not opened in "
"unmanaged mode",
fd);
});
} else {
ProcessEmitWarning(
this,
"File descriptor %d closed but not opened in unmanaged mode",
fd);
}
ProcessEmitWarning(
this, "File descriptor %d closed but not opened in unmanaged mode", fd);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ class Environment : public MemoryRetainer {
std::unique_ptr<v8::BackingStore> release_managed_buffer(const uv_buf_t& buf);

void AddUnmanagedFd(int fd);
void RemoveUnmanagedFd(int fd, bool schedule_native_immediate = false);
void RemoveUnmanagedFd(int fd);

template <typename T>
void ForEachRealm(T&& iterator) const;
Expand Down
4 changes: 0 additions & 4 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
uint32_t,
int64_t,
bool);
using CFunctionWithObjectInt32Fallback = void (*)(v8::Local<v8::Object>,
int32_t input,
v8::FastApiCallbackOptions&);
using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
const uint32_t input);
using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
Expand Down Expand Up @@ -78,7 +75,6 @@ class ExternalReferenceRegistry {
V(CFunctionCallbackWithTwoUint8Arrays) \
V(CFunctionCallbackWithTwoUint8ArraysFallback) \
V(CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
V(CFunctionWithObjectInt32Fallback) \
V(CFunctionWithUint32) \
V(CFunctionWithDoubleReturnDouble) \
V(CFunctionWithInt64Fallback) \
Expand Down
33 changes: 3 additions & 30 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace fs {

using v8::Array;
using v8::BigInt;
using v8::CFunction;
using v8::Context;
using v8::EscapableHandleScope;
using v8::FastApiCallbackOptions;
Expand Down Expand Up @@ -299,7 +298,7 @@ FileHandle::TransferData::~TransferData() {

BaseObjectPtr<BaseObject> FileHandle::TransferData::Deserialize(
Environment* env,
Local<v8::Context> context,
v8::Local<v8::Context> context,
std::unique_ptr<worker::TransferData> self) {
BindingData* bd = Realm::GetBindingData<BindingData>(context);
if (bd == nullptr) return {};
Expand Down Expand Up @@ -961,7 +960,7 @@ void Access(const FunctionCallbackInfo<Value>& args) {
}
}

static void Close(const FunctionCallbackInfo<Value>& args) {
void Close(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

const int argc = args.Length();
Expand All @@ -987,30 +986,6 @@ static void Close(const FunctionCallbackInfo<Value>& args) {
}
}

static void FastClose(Local<Object> recv,
int32_t fd,
// NOLINTNEXTLINE(runtime/references) This is V8 api.
v8::FastApiCallbackOptions& options) {
Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());

uv_fs_t req;
FS_SYNC_TRACE_BEGIN(close);
int err = uv_fs_close(nullptr, &req, fd, nullptr) < 0;
FS_SYNC_TRACE_END(close);
uv_fs_req_cleanup(&req);

if (err < 0) {
options.fallback = true;
} else {
// Note: Only remove unmanaged fds if the close was successful.
// RemoveUnmanagedFd() can call ProcessEmitWarning() which calls back into
// JS process.emitWarning() and violates the fast API protocol.
env->RemoveUnmanagedFd(fd, true /* schedule native immediate */);
}
}

CFunction fast_close_ = CFunction::Make(FastClose);

static void ExistsSync(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
Expand Down Expand Up @@ -3330,7 +3305,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
"getFormatOfExtensionlessFile",
GetFormatOfExtensionlessFile);
SetMethod(isolate, target, "access", Access);
SetFastMethod(isolate, target, "close", Close, &fast_close_);
SetMethod(isolate, target, "close", Close);
SetMethod(isolate, target, "existsSync", ExistsSync);
SetMethod(isolate, target, "open", Open);
SetMethod(isolate, target, "openFileHandle", OpenFileHandle);
Expand Down Expand Up @@ -3455,8 +3430,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {

registry->Register(GetFormatOfExtensionlessFile);
registry->Register(Close);
registry->Register(FastClose);
registry->Register(fast_close_.GetTypeInfo());
registry->Register(ExistsSync);
registry->Register(Open);
registry->Register(OpenFileHandle);
Expand Down
2 changes: 1 addition & 1 deletion src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define NODE_VERSION_IS_LTS 0
#define NODE_VERSION_LTS_CODENAME ""

#define NODE_VERSION_IS_RELEASE 0
#define NODE_VERSION_IS_RELEASE 1

#ifndef NODE_STRINGIFY
#define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
Expand Down
Loading