helloadhavan/github_issues huggingface dataset:
Repository: nodejs/node
Pull request: test: convert readdir test to use test runner

This PR is the result of a code & learn session at NodeConf EU 2024 in Waterford, Ireland.

It was part of a wider initiative to update Node.js tests to make use of the new built-in test apparatus.

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: test/parallel/test-fs-readdir-recursive.js
patch: @@ -1,14 +1,18 @@
 'use strict';
-const common = require('../common');
-const fs = require('fs');
-const net = require('net');
 
+const { PIPE, mustCall } = require('../common');
 const tmpdir = require('../common/tmpdir');
-tmpdir.refresh();
+const { test } = require('node:test');
+const fs = require('node:fs');
+const net = require('node:net');
 
-const server = net.createServer().listen(common.PIPE, common.mustCall(() => {
-  // The process should not crash
-  // See https://github.com/nodejs/node/issues/52159
-  fs.readdirSync(tmpdir.path, { recursive: true });
-  server.close();
-}));
+test('readdir should not recurse into Unix domain sockets', (t, done) => {
+  tmpdir.refresh();
+  const server = net.createServer().listen(PIPE, mustCall(() => {
+    // The process should not crash
+    // See https://github.com/nodejs/node/issues/52159
+    fs.readdirSync(tmpdir.path, { recursive: true });
+    server.close();
+    done();
+  }));
+});
Repository: denoland/deno
Pull request: perf(ext/node): improve `Buffer.from(buffer)`

Benchmark code from #24341.

```shellsession
$ deno run --allow-hrtime bench.mjs
6479.111583
$ target/release/deno run --allow-hrtime bench.mjs
962.753875
$ node bench.mjs
855.174875
```


Changed files:
filename: ext/node/polyfills/internal/buffer.mjs
patch: @@ -220,12 +220,9 @@ function fromString(string, encoding) {
   return buf;
 }
 
-function fromArrayLike(array) {
-  const length = array.length < 0 ? 0 : checked(array.length) | 0;
-  const buf = createBuffer(length);
-  for (let i = 0; i < length; i += 1) {
-    buf[i] = array[i] & 255;
-  }
+function fromArrayLike(obj) {
+  const buf = new Uint8Array(obj);
+  Object.setPrototypeOf(buf, Buffer.prototype);
   return buf;
 }
 
@@ -234,6 +231,7 @@ function fromObject(obj) {
     if (typeof obj.length !== "number") {
       return createBuffer(0);
     }
+
     return fromArrayLike(obj);
   }
 

filename: tests/unit_node/buffer_test.ts
patch: @@ -534,15 +534,18 @@ Deno.test({
 });
 
 Deno.test({
-  name: "[node/buffer] Buffer from another buffer creates a Buffer",
+  name: "[node/buffer] Buffer from another buffer creates a copy",
   fn() {
-    const buffer: Buffer = Buffer.from(Buffer.from("test"));
-    assertEquals(buffer.length, 4, "Buffer length should be 4");
+    const buffer1: Buffer = Buffer.from("test");
+    const buffer2: Buffer = Buffer.from(buffer1);
+    assertEquals(buffer2.length, 4, "Buffer length should be 4");
     assertEquals(
-      buffer.toString(),
+      buffer2.toString(),
       "test",
       "Buffer to string should recover the string",
     );
+    buffer1[0] = 114;
+    assertEquals(buffer2.toString(), "test", "Buffer should be a copy");
   },
 });
Repository: denoland/deno
Pull request: Revert "perf: improve Buffer.from(buf) by 29x"

https://github.com/denoland/deno/pull/24341#discussion_r1655247367

Reverts denoland/deno#24341

Changed files:
filename: ext/node/polyfills/internal/buffer.mjs
patch: @@ -229,22 +229,11 @@ function fromArrayLike(array) {
   return buf;
 }
 
-function fromUint8Array(u8) {
-  const buf = new Uint8Array(u8.buffer, u8.byteOffset, u8.byteLength);
-  Object.setPrototypeOf(buf, Buffer.prototype);
-  return buf.slice();
-}
-
 function fromObject(obj) {
   if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {
     if (typeof obj.length !== "number") {
       return createBuffer(0);
     }
-
-    if (obj instanceof Uint8Array) {
-      return fromUint8Array(obj);
-    }
-
     return fromArrayLike(obj);
   }
Repository: electron/electron
Pull request: feat: accept-encoding zstd

#### Description of Change

Set the default network context params' `enable_zstd` flag to `true` to enable zstd encoding. As per 43124, this is true for requests made in Chromium but was not true in Electron.

Closes #43124.

#### Checklist

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: Enabled zstd compression in net http requests.

Changed files:
filename: shell/browser/net/system_network_context_manager.cc
patch: @@ -195,6 +195,8 @@ SystemNetworkContextManager::CreateDefaultNetworkContextParams() {
 void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(
     network::mojom::NetworkContextParams* network_context_params) {
   network_context_params->enable_brotli = true;
+  network_context_params->enable_zstd =
+      base::FeatureList::IsEnabled(net::features::kZstdContentEncoding);
 
   network_context_params->enable_referrers = true;
Repository: facebook/react
Pull request: [DevTools] Enable logger for internal build of DevTools extensions

## Summary

Enables logging (`enableLogger` feature flag) for internal (fb-only) builds of DevTools extensions

## How did you test this change?

- yarn flow
- yarn test
- yarn test-build-devtools
- ran internal build manually `yarn build:chrome:fb` and verified that events were correctly communicated to iframe that loads an internal endpoint.


Changed files:
filename: packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js
patch: @@ -16,7 +16,7 @@
 export const enableProfilerChangedHookIndices = true;
 export const isInternalFacebookBuild = true;
 export const enableNamedHooksFeature = true;
-export const enableLogger = false;
+export const enableLogger = true;
 export const consoleManagedByDevToolsDuringStrictMode = true;
 
 /************************************************************************
Repository: ggml-org/llama.cpp
Pull request: Llama4 RoPE fix

Llama4 Scout config.json changed RoPE scaling, so we need to remove the assert since it breaks on Llama 4

Changed files:
filename: convert_hf_to_gguf.py
patch: @@ -1750,7 +1750,7 @@ def generate_extra_tensors(self) -> Iterable[tuple[str, Tensor]]:
 
                 low_freq_wavelen = old_context_len / low_freq_factor
                 high_freq_wavelen = old_context_len / high_freq_factor
-                assert low_freq_wavelen != high_freq_wavelen
+                # assert low_freq_wavelen != high_freq_wavelen # Errors for Llama4
 
                 rope_factors = []
                 for freq in freqs:
Repository: vercel/next.js
Pull request: Output server.mjs for standalone with type: module

This ensures we output `server.mjs` when `type: 'module'` is configured for a project using `standalone` mode. This also ensures we copy the `package.json` to the standalone folder as we were previously only copying it if it was included in the traced assets. 

Changed files:
filename: packages/next/src/build/utils.ts
patch: @@ -1544,8 +1544,19 @@ export async function copyTracedFiles(
   }
   try {
     const packageJsonPath = path.join(distDir, '../package.json')
-    const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'))
+    const packageJsonContent = await fs.readFile(packageJsonPath, 'utf8')
+    const packageJson = JSON.parse(packageJsonContent)
     moduleType = packageJson.type === 'module'
+
+    // we always copy the package.json to the standalone
+    // folder to ensure any resolving logic is maintained
+    const packageJsonOutputPath = path.join(
+      outputPath,
+      path.relative(tracingRoot, dir),
+      'package.json'
+    )
+    await fs.mkdir(path.dirname(packageJsonOutputPath), { recursive: true })
+    await fs.writeFile(packageJsonOutputPath, packageJsonContent)
   } catch {}
   const copiedFiles = new Set()
   await fs.rm(outputPath, { recursive: true, force: true })
@@ -1676,7 +1687,7 @@ export async function copyTracedFiles(
   const serverOutputPath = path.join(
     outputPath,
     path.relative(tracingRoot, dir),
-    'server.js'
+    moduleType ? 'server.mjs' : 'server.js'
   )
   await fs.mkdir(path.dirname(serverOutputPath), { recursive: true })
 

filename: test/production/standalone-mode/type-module/index.test.ts
patch: @@ -39,7 +39,9 @@ describe('type-module', () => {
 
     await fs.move(staticSrc, staticDest)
 
-    const serverFile = join(standalonePath, 'server.js')
+    expect(fs.existsSync(join(standalonePath, 'package.json'))).toBe(true)
+
+    const serverFile = join(standalonePath, 'server.mjs')
     const appPort = await findPort()
     const server = await initNextServerScript(
       serverFile,
Repository: denoland/deno
Pull request: perf: optimize Buffer.from("base64") for forgiving-base64 conforming input

Don't try to clean the input unless decoding fails at first. A ~3x improvement for forgiving-base64 conforming input.

```
$ target/release/deno run  -A ./bench.mjs
593.3049169
$ deno run -A ./bench.mjs
1912.209888
$ node bench.mjs
989.406209
```

```js
import { Buffer } from "node:buffer";

const buffer = Buffer.alloc(1024 * 10, "latin1");
const input = buffer.toString("base64");
const start = performance.now();
for (let i = 0; i < 100000; i++) {
	Buffer.from(input, "base64");
}

console.log(performance.now() - start);
```

Ref #24323 

Changed files:
filename: ext/node/polyfills/internal_binding/_utils.ts
patch: @@ -18,9 +18,13 @@ export function asciiToBytes(str: string) {
 }
 
 export function base64ToBytes(str: string) {
-  str = base64clean(str);
-  str = str.replaceAll("-", "+").replaceAll("_", "/");
-  return forgivingBase64Decode(str);
+  try {
+    return forgivingBase64Decode(str);
+  } catch {
+    str = base64clean(str);
+    str = str.replaceAll("-", "+").replaceAll("_", "/");
+    return forgivingBase64Decode(str);
+  }
 }
 
 const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
Repository: electron/electron
Pull request: feat: accept-encoding zstd

Backport of #43150

See that PR for details.


Notes: Enabled zstd compression in net http requests.

Changed files:
filename: shell/browser/net/system_network_context_manager.cc
patch: @@ -198,6 +198,8 @@ SystemNetworkContextManager::CreateDefaultNetworkContextParams() {
 void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(
     network::mojom::NetworkContextParams* network_context_params) {
   network_context_params->enable_brotli = true;
+  network_context_params->enable_zstd =
+      base::FeatureList::IsEnabled(net::features::kZstdContentEncoding);
 
   network_context_params->enable_referrers = true;
Repository: facebook/react
Pull request: CodeSandbox CI: Fall back to local build

The `download-experimental-build` script has been flaky on CodeSandbox CI, I think because of GitHub rate limiting.

Until we figure out how to fix that, I've updated it to fall back to a local build.

Changed files:
filename: package.json
patch: @@ -144,6 +144,6 @@
     "publish-prereleases": "node ./scripts/release/publish-using-ci-workflow.js",
     "download-build": "node ./scripts/release/download-experimental-build.js",
     "download-build-for-head": "node ./scripts/release/download-experimental-build.js --commit=$(git rev-parse HEAD)",
-    "download-build-in-codesandbox-ci": "cd scripts/release && yarn install && cd ../../ && yarn download-build-for-head"
+    "download-build-in-codesandbox-ci": "cd scripts/release && yarn install && cd ../../ && yarn download-build-for-head || yarn build-combined --type=node react/index react-dom scheduler"
   }
 }
Repository: ggml-org/llama.cpp
Pull request: Set cache directory in rpc-server.cpp on FreeBSD


Changed files:
filename: examples/rpc/rpc-server.cpp
patch: @@ -126,7 +126,7 @@ static std::string fs_get_cache_directory() {
     if (getenv("LLAMA_CACHE")) {
         cache_directory = std::getenv("LLAMA_CACHE");
     } else {
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
         if (std::getenv("XDG_CACHE_HOME")) {
             cache_directory = std::getenv("XDG_CACHE_HOME");
         } else {
@@ -136,7 +136,9 @@ static std::string fs_get_cache_directory() {
         cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");
 #elif defined(_WIN32)
         cache_directory = std::getenv("LOCALAPPDATA");
-#endif // __linux__
+#else
+#  error Unknown architecture
+#endif
         cache_directory = ensure_trailing_slash(cache_directory);
         cache_directory += "llama.cpp";
     }
Repository: denoland/deno
Pull request: feat: add module.parent

This field is deprecated but still used by the ecosystem, so let's just support it.

Changed files:
filename: ext/node/polyfills/01_require.js
patch: @@ -475,6 +475,7 @@ function Module(id = "", parent) {
   updateChildren(parent, this, false);
   this.filename = null;
   this.loaded = false;
+  this.parent = parent;
   this.children = [];
 }
Repository: nodejs/node
Pull request: doc: add history entries for JSON modules stabilization

Refs: https://github.com/nodejs/node/pull/55333
<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: doc/api/esm.md
patch: @@ -7,6 +7,11 @@
 <!-- YAML
 added: v8.5.0
 changes:
+  - version:
+    - v23.1.0
+    - v18.20.5
+    pr-url: https://github.com/nodejs/node/pull/55333
+    description: Import attributes are no longer experimental.
   - version:
     - v21.0.0
     - v20.10.0
@@ -628,6 +633,15 @@ separate cache.
 
 ## JSON modules
 
+<!-- YAML
+changes:
+  - version:
+    - v23.1.0
+    - v18.20.5
+    pr-url: https://github.com/nodejs/node/pull/55333
+    description: JSON modules are no longer experimental.
+-->
+
 > Stability: 2 - Stable
 
 JSON files can be referenced by `import`:
Repository: facebook/react
Pull request: Fixed Link on Documentation

The Documentation link via https://reactjs.org/docs on line 23 doesn't work and shows an Page Not Found Error page handler.

This change fixes the UX a bit for now, we could also default it to (https://reactjs.org/docs/getting-started.html) however this creates a bit of redundancy.

<!--
  Thanks for submitting a pull request!
  We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory.

  Before submitting a pull request, please make sure the following is done:

  1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`.
  2. Run `yarn` in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
  5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`.
  6. If you need a debugger, run `yarn debug-test --watch TestName`, open `chrome://inspect`, and press "Inspect".
  7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
  8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

  Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

<!--
 Explain the **motivation** for making this change. What existing problem does the pull request solve?
-->

## How did you test this change?

<!--
  Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface.
  How exactly did you verify that your PR solves the issue you wanted to solve?
  If you leave this empty, your PR will very likely be closed.
-->


Changed files:
filename: README.md
patch: @@ -20,7 +20,7 @@ You can use React as a `<script>` tag from a [CDN](https://reactjs.org/docs/cdn-
 
 ## Documentation
 
-You can find the React documentation [on the website](https://reactjs.org/docs).  
+You can find the React documentation [on the website](https://reactjs.org/).  
 
 Check out the [Getting Started](https://reactjs.org/docs/getting-started.html) page for a quick overview.
Repository: denoland/deno
Pull request: fix(ext/node): ignore stream error during enqueue

This ignores the stream enqueue error but the right fix would be to cleanup resources correctly when a client closes a streaming response prematurely but it is not a priority right now.

Closes https://github.com/denoland/deno/issues/22820


Changed files:
filename: ext/node/polyfills/http.ts
patch: @@ -1346,10 +1346,14 @@ export class ServerResponse extends NodeWritable {
   #socketOverride: any | null = null;
 
   static #enqueue(controller: ReadableStreamDefaultController, chunk: Chunk) {
-    if (typeof chunk === "string") {
-      controller.enqueue(ENCODER.encode(chunk));
-    } else {
-      controller.enqueue(chunk);
+    try {
+      if (typeof chunk === "string") {
+        controller.enqueue(ENCODER.encode(chunk));
+      } else {
+        controller.enqueue(chunk);
+      }
+    } catch (_) {
+      // The stream might have been closed. Ignore the error.
     }
   }
 

filename: tests/unit_node/http_test.ts
patch: @@ -1130,3 +1130,52 @@ Deno.test("[node/http] server closeIdleConnections shutdown", async () => {
 
   await promise;
 });
+
+Deno.test("[node/http] client closing a streaming response doesn't terminate server", async () => {
+  let interval: number;
+  const server = http.createServer((req, res) => {
+    res.writeHead(200, { "Content-Type": "text/plain" });
+    interval = setInterval(() => {
+      res.write("Hello, world!\n");
+    }, 100);
+    req.on("end", () => {
+      clearInterval(interval);
+      res.end();
+    });
+    req.on("error", (err) => {
+      console.error("Request error:", err);
+      clearInterval(interval);
+      res.end();
+    });
+  });
+
+  const deferred1 = Promise.withResolvers<void>();
+  server.listen(0, () => {
+    // deno-lint-ignore no-explicit-any
+    const port = (server.address() as any).port;
+
+    // Create a client connection to the server
+    const client = net.createConnection({ port }, () => {
+      console.log("Client connected to server");
+
+      // Write data to the server
+      client.write("GET / HTTP/1.1\r\n");
+      client.write("Host: localhost\r\n");
+      client.write("Connection: close\r\n");
+      client.write("\r\n");
+
+      // End the client connection prematurely while reading data
+      client.on("data", (data) => {
+        assert(data.length > 0);
+        client.end();
+        setTimeout(() => deferred1.resolve(), 100);
+      });
+    });
+  });
+
+  await deferred1.promise;
+  assertEquals(server.listening, true);
+  server.close();
+  assertEquals(server.listening, false);
+  clearInterval(interval!);
+});