helloadhavan/github_issues huggingface dataset:
Repository: denoland/deno
Pull request: fix(ext/node): fix Buffer.concat truncating buffers larger than 4GB

## Summary

- Replace `| 0` (32-bit integer truncation) with `MathTrunc()` in `checked()`, `_allocUnsafe()`, and `fromString()` in the Node.js Buffer polyfill
- This fixes `Buffer.concat` and `Buffer.allocUnsafe` silently truncating buffers with sizes exceeding 2^32 (e.g. `(2**32 + 5) | 0` → `5`)

Closes #32895

## Test plan

- [x] Added tests for `Buffer.allocUnsafe` and `Buffer.concat` with >4GB sizes (marked `ignore: true` due to memory requirements)
- [x] Existing buffer tests pass (`./x test-node buffer`)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Changed files:
filename: ext/node/polyfills/internal/buffer.mjs
patch: @@ -423,7 +423,7 @@ Buffer.alloc = function alloc(size, fill, encoding) {
 
 function _allocUnsafe(size) {
   assertSize(size);
-  return createBuffer(size < 0 ? 0 : checked(size) | 0);
+  return createBuffer(size < 0 ? 0 : checked(size));
 }
 
 /**
@@ -465,7 +465,7 @@ function fromString(string, encoding) {
   }
 
   const maxLength = Buffer.poolSize >>> 1;
-  const length = byteLength(string, encoding) | 0;
+  const length = MathTrunc(byteLength(string, encoding));
   if (length >= maxLength) {
     let buf = createBuffer(length);
     const actual = buf.write(string, encoding);
@@ -518,7 +518,7 @@ function checked(length) {
         NumberPrototypeToString(kMaxLength, 16) + " bytes",
     );
   }
-  return length | 0;
+  return MathTrunc(length);
 }
 
 export function SlowBuffer(length) {

filename: tests/unit_node/buffer_test.ts
patch: @@ -278,6 +278,29 @@ Deno.test({
   },
 });
 
+Deno.test({
+  name: "[node/buffer] Buffer.allocUnsafe does not truncate lengths > 2^32",
+  ignore: true, // requires >4GB of memory
+  fn() {
+    const size = 2 ** 32 + 5;
+    const buf = Buffer.allocUnsafe(size);
+    assertEquals(buf.length, size);
+  },
+});
+
+Deno.test({
+  name: "[node/buffer] Buffer concat does not truncate buffers larger than 4GB",
+  ignore: true, // requires >4GB of memory
+  fn() {
+    const size = 2 ** 32 + 5;
+    const largeBuffer = Buffer.alloc(size);
+    largeBuffer.fill(111);
+    const result = Buffer.concat([largeBuffer]);
+    assertEquals(result.length, size);
+    assertEquals(Array.from(result.subarray(0, 5)), [111, 111, 111, 111, 111]);
+  },
+});
+
 Deno.test({
   name: "[node/buffer] Buffer 8 bit unsigned integers",
   fn() {
Repository: facebook/react
Pull request: [dependabot] Remove stale directories from config

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom):
* #31074
* __->__ #31073



Changed files:
filename: .github/dependabot.yml
patch: @@ -40,11 +40,6 @@ updates:
     schedule:
       interval: "weekly"
     open-pull-requests-limit: 0
-  - package-ecosystem: "npm"
-    directory: "/fixtures/fiber-triangle"
-    schedule:
-      interval: "weekly"
-    open-pull-requests-limit: 0
   - package-ecosystem: "npm"
     directory: "/fixtures/fizz"
     schedule:
@@ -60,11 +55,6 @@ updates:
     schedule:
       interval: "weekly"
     open-pull-requests-limit: 0
-  - package-ecosystem: "npm"
-    directory: "/fixtures/flight-browser"
-    schedule:
-      interval: "weekly"
-    open-pull-requests-limit: 0
   - package-ecosystem: "npm"
     directory: "/fixtures/flight-esm"
     schedule:
Repository: ollama/ollama
Pull request: Skip max queue test on remote

This test needs to be able to adjust the queue size down from our default setting for a reliable test, so it needs to skip on remote test execution mode.

Changed files:
filename: integration/max_queue_test.go
patch: @@ -19,6 +19,11 @@ import (
 )
 
 func TestMaxQueue(t *testing.T) {
+	if os.Getenv("OLLAMA_TEST_EXISTING") != "" {
+		t.Skip("Max Queue test requires spawing a local server so we can adjust the queue size")
+		return
+	}
+
 	// Note: This test can be quite slow when running in CPU mode, so keep the threadCount low unless your on GPU
 	// Also note that by default Darwin can't sustain > ~128 connections without adjusting limits
 	threadCount := 32
@@ -109,9 +114,9 @@ func TestMaxQueue(t *testing.T) {
 	slog.Info("generate done, waiting for embeds")
 	embedwg.Wait()
 
+	slog.Info("embeds completed", "success", succesCount, "busy", busyCount, "reset", resetByPeerCount, "canceled", canceledCount)
 	require.Equal(t, resetByPeerCount, 0, "Connections reset by peer, have you updated your fd and socket limits?")
 	require.True(t, busyCount > 0, "no requests hit busy error but some should have")
 	require.True(t, canceledCount == 0, "no requests should have been canceled due to timeout")
 
-	slog.Info("embeds completed", "success", succesCount, "busy", busyCount, "reset", resetByPeerCount, "canceled", canceledCount)
 }
Repository: vercel/next.js
Pull request: fix: incorrect canonicalUrl set when using output: export

After the changes in https://github.com/vercel/next.js/commit/5ccc9078e094215e6c891c38a31fb94cda03456e, when in `output: 'export'` mode, the `canonicalUrl` value was getting corrupted to be set to one of the URLs of the RSC responses (eg `/another.txt`). This is because the original `url` gets mutated to append a `.txt` extension for the RSC requests.

This ensures we preserve the original canonical URL so it doesn't get corrupted when we mutate the pathname.

Failing test ref: https://github.com/vercel/next.js/actions/runs/18607156298/job/53060147186#step:34:151

Changed files:
filename: packages/next/src/client/components/router-reducer/fetch-server-response.ts
patch: @@ -158,6 +158,10 @@ export async function fetchServerResponse(
     headers[NEXT_URL] = nextUrl
   }
 
+  // In static export mode, we need to modify the URL to request the .txt file,
+  // but we should preserve the original URL for the canonical URL and error handling.
+  const originalUrl = url
+
   try {
     // When creating a "temporary" prefetch (the "on-demand" prefetch that gets created on navigation, if one doesn't exist)
     // we send the request with a "high" priority as it's in response to a user interaction that could be blocking a transition.
@@ -198,7 +202,7 @@ export async function fetchServerResponse(
     )
 
     const responseUrl = urlToUrlWithoutFlightMarker(new URL(res.url))
-    const canonicalUrl = res.redirected ? responseUrl : url
+    const canonicalUrl = res.redirected ? responseUrl : originalUrl
 
     const contentType = res.headers.get('content-type') || ''
     const interception = !!res.headers.get('vary')?.includes(NEXT_URL)
@@ -285,15 +289,15 @@ export async function fetchServerResponse(
   } catch (err) {
     if (!abortController.signal.aborted) {
       console.error(
-        `Failed to fetch RSC payload for ${url}. Falling back to browser navigation.`,
+        `Failed to fetch RSC payload for ${originalUrl}. Falling back to browser navigation.`,
         err
       )
     }
 
     // If fetch fails handle it like a mpa navigation
     // TODO-APP: Add a test for the case where a CORS request fails, e.g. external url redirect coming from the response.
     // See https://github.com/vercel/next.js/issues/43605#issuecomment-1451617521 for a reproduction.
-    return url.toString()
+    return originalUrl.toString()
   }
 }
Repository: electron/electron
Pull request: fix: `webContents.downloadURL()` did not support referer header

Backport of #47625

See that PR for details.


Notes: Fixed a bug where the `Referer` header was not being set correctly when using `webContents.downloadURL()`.

Changed files:
filename: shell/browser/api/electron_api_web_contents.cc
patch: @@ -2398,6 +2398,13 @@ void WebContents::DownloadURL(const GURL& url, gin::Arguments* args) {
       content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
           web_contents(), url, MISSING_TRAFFIC_ANNOTATION));
   for (const auto& [name, value] : headers) {
+    if (base::ToLowerASCII(name) ==
+        base::ToLowerASCII(net::HttpRequestHeaders::kReferer)) {
+      // Setting a Referer header with HTTPS scheme while the download URL's
+      // scheme is HTTP might lead to download failure.
+      download_params->set_referrer(GURL(value));
+      continue;
+    }
     download_params->add_request_header(name, value);
   }
 

filename: spec/api-session-spec.ts
patch: @@ -1289,6 +1289,53 @@ describe('session module', () => {
         expect(item.getContentDisposition()).to.equal(contentDisposition);
       });
 
+      it('can perform a download with referer header', async () => {
+        const server = http.createServer((req, res) => {
+          const { referer } = req.headers;
+          if (!referer || !referer.startsWith('http://www.electronjs.org')) {
+            res.statusCode = 403;
+            res.end();
+          } else {
+            res.writeHead(200, {
+              'Content-Length': mockPDF.length,
+              'Content-Type': 'application/pdf',
+              'Content-Disposition': req.url === '/?testFilename' ? 'inline' : contentDisposition
+            });
+            res.end(mockPDF);
+          }
+        });
+
+        const { port } = await listen(server);
+
+        const w = new BrowserWindow({ show: false });
+        const downloadDone: Promise<Electron.DownloadItem> = new Promise((resolve) => {
+          w.webContents.session.once('will-download', (e, item) => {
+            item.savePath = downloadFilePath;
+            item.on('done', () => {
+              try {
+                resolve(item);
+              } catch { }
+            });
+          });
+        });
+
+        w.webContents.downloadURL(`${url}:${port}`, {
+          headers: {
+            // Setting a Referer header with HTTPS scheme while the download URL's
+            // scheme is HTTP might lead to download failure.
+            referer: 'http://www.electronjs.org'
+          }
+        });
+
+        const item = await downloadDone;
+        expect(item.getState()).to.equal('completed');
+        expect(item.getFilename()).to.equal('mock.pdf');
+        expect(item.getMimeType()).to.equal('application/pdf');
+        expect(item.getReceivedBytes()).to.equal(mockPDF.length);
+        expect(item.getTotalBytes()).to.equal(mockPDF.length);
+        expect(item.getContentDisposition()).to.equal(contentDisposition);
+      });
+
       it('throws when called with invalid headers', () => {
         const w = new BrowserWindow({ show: false });
         expect(() => {
Repository: ggml-org/llama.cpp
Pull request: CUDA: fix KQ max calculation

Fixes https://github.com/ggml-org/llama.cpp/issues/18444 .

Unpadded K/V tensors are handled in the CUDA backend by padding the local data structures upon load with zeros so that upon use in a dot product they don't affect the accumulators. However, these are not supposed to be used for calculating KQ maxima and sums. The MMA kernel has a bug on master where sometimes the zeros are incorrectly used for the KQ maxima which can result in numerical issues if the actual KQ values are << 0. Our tests don't detect this because we use input values close to 0. https://github.com/ggml-org/llama.cpp/pull/18472 fixes only a symptom but not the root cause.

Changed files:
filename: ggml/src/ggml-cuda/fattn-mma-f16.cuh
patch: @@ -531,7 +531,7 @@ static __device__ __forceinline__ void flash_attn_ext_f16_iter(
         for (int k0 = 0; k0 < nbatch_fa; k0 += np*T_C_KQ::I) {
 #pragma unroll
             for (int l = 0; l < T_C_KQ::ne; ++l) {
-                if (!oob_check || k0 + T_C_KQ::get_i(l) < k_VKQ_sup) {
+                if (!oob_check || k0 + (threadIdx.y % np)*T_C_KQ::I + T_C_KQ::get_i(l) < k_VKQ_sup) {
                     KQ_max_new[l % 2] = fmaxf(KQ_max_new[l % 2], KQ_C[k0/(np*T_C_KQ::I)].x[l] + FATTN_KQ_MAX_OFFSET);
                 }
             }
@@ -583,7 +583,7 @@ static __device__ __forceinline__ void flash_attn_ext_f16_iter(
         for (int k0 = 0; k0 < nbatch_fa; k0 += np*T_C_KQ::J) {
 #pragma unroll
             for (int l = 0; l < T_C_KQ::ne; ++l) {
-                if (!oob_check || k0 + T_C_KQ::get_j(l) < k_VKQ_sup) {
+                if (!oob_check || k0 + (threadIdx.y % np)*T_C_KQ::J + T_C_KQ::get_j(l) < k_VKQ_sup) {
                     // Turing + Volta:
                     KQ_max_new[(l/2) % 2] = fmaxf(KQ_max_new[(l/2) % 2], KQ_C[(k0/(np*T_C_KQ::J))].x[l] + FATTN_KQ_MAX_OFFSET);
                 }
Repository: ollama/ollama
Pull request: changed line display to be calculated with runewidth

Calculates line length using `runewidth` instead of `len(string)` as `len(string)` produces the number of bytes in that string (often resulting in an incorrect calculation of display length for multi-width runes). Now cuts lines accordingly for multi-byte characters (Russian, latin, etc) as well as word-wraps for multi-width characters (Chinese, Japanese, Korean)

Old Russian: 
<img width="560" alt="Screenshot 2024-05-15 at 5 05 42 PM" src="https://github.com/ollama/ollama/assets/76125168/50bda24b-7fff-4cc9-8e85-6f1b4f006a65">

New: Russian
<img width="555" alt="Screenshot 2024-05-15 at 5 01 21 PM" src="https://github.com/ollama/ollama/assets/76125168/a664d1f0-c321-4993-bad7-2c2e066e6a10">

Old: Chinese
<img width="576" alt="Screenshot 2024-05-15 at 5 10 09 PM" src="https://github.com/ollama/ollama/assets/76125168/5d47f924-9467-4f3b-ba1d-515072f875f3">

New: Chinese
<img width="572" alt="Screenshot 2024-05-15 at 5 15 12 PM" src="https://github.com/ollama/ollama/assets/76125168/275e39dd-c89f-4545-9323-0aba1c8060e2">



Changed files:
filename: cmd/cmd.go
patch: @@ -25,7 +25,7 @@ import (
 	"time"
 
 	"github.com/containerd/console"
-
+	"github.com/mattn/go-runewidth"
 	"github.com/olekukonko/tablewriter"
 	"github.com/spf13/cobra"
 	"golang.org/x/crypto/ssh"
@@ -744,20 +744,27 @@ func displayResponse(content string, wordWrap bool, state *displayResponseState)
 	if wordWrap && termWidth >= 10 {
 		for _, ch := range content {
 			if state.lineLength+1 > termWidth-5 {
-				if len(state.wordBuffer) > termWidth-10 {
+
+				if runewidth.StringWidth(state.wordBuffer) > termWidth-10 {
 					fmt.Printf("%s%c", state.wordBuffer, ch)
 					state.wordBuffer = ""
 					state.lineLength = 0
 					continue
 				}
 
 				// backtrack the length of the last word and clear to the end of the line
-				fmt.Printf("\x1b[%dD\x1b[K\n", len(state.wordBuffer))
+				fmt.Printf("\x1b[%dD\x1b[K\n", runewidth.StringWidth(state.wordBuffer))
 				fmt.Printf("%s%c", state.wordBuffer, ch)
-				state.lineLength = len(state.wordBuffer) + 1
+				chWidth := runewidth.RuneWidth(ch)
+
+				state.lineLength = runewidth.StringWidth(state.wordBuffer) + chWidth
 			} else {
 				fmt.Print(string(ch))
-				state.lineLength += 1
+				state.lineLength += runewidth.RuneWidth(ch)
+				if runewidth.RuneWidth(ch) >= 2 {
+					state.wordBuffer = ""
+					continue
+				}
 
 				switch ch {
 				case ' ':
Repository: facebook/react
Pull request: [ez] Update deprecated action

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom):
* __->__ #31047
* #31046
* #31045



Changed files:
filename: .github/workflows/runtime_commit_artifacts.yml
patch: @@ -82,7 +82,7 @@ jobs:
         working-directory: scripts/release
       - name: Download artifacts for base revision
         run: |
-          GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build.js --commit=${{ inputs.commit_sha || github.event.workflow_run.head_sha }}
+          GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build.js --commit=${{ inputs.commit_sha || github.sha }}
       - name: Display structure of build
         run: ls -R build
       - name: Strip @license from eslint plugin and react-refresh
@@ -145,9 +145,9 @@ jobs:
           ls -R ./compiled-rn
       - name: Add REVISION files
         run: |
-          echo ${{ github.event.workflow_run.head_sha }} >> ./compiled/facebook-www/REVISION
+          echo ${{ github.sha }} >> ./compiled/facebook-www/REVISION
           cp ./compiled/facebook-www/REVISION ./compiled/facebook-www/REVISION_TRANSFORMS
-          echo ${{ github.event.workflow_run.head_sha}} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
+          echo ${{ github.sha}} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
       - name: "Get current version string"
         id: get_current_version
         run: |
Repository: facebook/react
Pull request: [ez] Make commit sha clickable for fbsource

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom):
* #31047
* __->__ #31046
* #31045



Changed files:
filename: .github/workflows/runtime_commit_artifacts.yml
patch: @@ -82,7 +82,7 @@ jobs:
         working-directory: scripts/release
       - name: Download artifacts for base revision
         run: |
-          GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build.js --commit=${{ inputs.commit_sha || github.event.workflow_run.head_sha }}
+          GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build.js --commit=${{ inputs.commit_sha || github.sha }}
       - name: Display structure of build
         run: ls -R build
       - name: Strip @license from eslint plugin and react-refresh
@@ -145,9 +145,9 @@ jobs:
           ls -R ./compiled-rn
       - name: Add REVISION files
         run: |
-          echo ${{ github.event.workflow_run.head_sha }} >> ./compiled/facebook-www/REVISION
+          echo ${{ github.sha }} >> ./compiled/facebook-www/REVISION
           cp ./compiled/facebook-www/REVISION ./compiled/facebook-www/REVISION_TRANSFORMS
-          echo ${{ github.event.workflow_run.head_sha}} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
+          echo ${{ github.sha}} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
       - name: "Get current version string"
         id: get_current_version
         run: |
Repository: vercel/next.js
Pull request: Update prefetching.mdx providing more clarity on the usage of `router.prefetch()`

## What
Updated `prefetching.mdx` in the App Router documentation providing more clarity on the usage of `router.prefetch()`. 

## Why
We found the current section on `Manual Prefetching` to be lacking in detail and a bit misleading as well.

The issue with the current version of the documentation is that the code snippet provided:
```tsx
const router = useRouter();
router.prefetch();
```
Makes it seem like `router.prefetch()` can be called at the same level as `useRouter()`, i.e. in the component body, even though that causes the page to crash for many possible reasons, such as `window is not defined`, or `Router action dispatched before initialization.`.

I am not sure if this is helpful/correct or not, just thought this may help someone. If not feel free to close this PR. Thanks in advance for your time.

## Reproduction
Here is a codesandbox reproducing the issue that occurs if you follow the code snippet trivially:
https://codesandbox.io/p/devbox/s5pmsj

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the PR. (Done)
- Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide (Done)


Closes NEXT-
Fixes #

-->


Changed files:
filename: docs/01-app/02-guides/prefetching.mdx
patch: @@ -58,16 +58,27 @@ Automatic prefetching runs only in production. Disable with `prefetch={false}` o
 
 ## Manual prefetch
 
+To do manual prefetching, import the `useRouter` hook from `next/navigation`, and call `router.prefetch()` to warm routes outside the viewport or in response to analytics, hover, scroll, etc.
+
 ```tsx
 'use client'
 
 import { useRouter } from 'next/navigation'
+import { CustomLink } from '@components/link'
+
+export function PricingCard() {
+  const router = useRouter()
 
-const router = useRouter()
-router.prefetch('/pricing')
+  return (
+    <div onMouseEnter={() => router.prefetch('/pricing')}>
+      {/* other UI elements */}
+      <CustomLink href="/pricing">View Pricing</CustomLink>
+    </div>
+  )
+}
 ```
 
-Call `router.prefetch()` to warm routes outside the viewport or in response to analytics, hover, scroll, etc.
+If the intent is to prefetch a URL when a component loads, see the extending or rejecting a link [example].
 
 ## Hover-triggered prefetch
Repository: ggml-org/llama.cpp
Pull request: llama : fix typo in comment in llama-kv-cache.h [no ci]


Changed files:
filename: src/llama-kv-cache.h
patch: @@ -305,7 +305,7 @@ class llama_kv_cache_context : public llama_memory_context_i {
             bool do_shift,
             stream_copy_info sc_info);
 
-    // used to create a batch procesing context from a batch
+    // used to create a batch processing context from a batch
     llama_kv_cache_context(
             llama_kv_cache * kv,
             slot_info_vec_t sinfos,
Repository: ollama/ollama
Pull request: Updating software for read me

Updating read me file.

Changed files:
filename: README.md
patch: @@ -391,6 +391,7 @@ See the [API documentation](./docs/api.md) for all endpoints.
 - [AI Telegram Bot](https://github.com/tusharhero/aitelegrambot) (Telegram bot using Ollama in backend)
 - [AI ST Completion](https://github.com/yaroslavyaroslav/OpenAI-sublime-text) (Sublime Text 4 AI assistant plugin with Ollama support)
 - [Discord-Ollama Chat Bot](https://github.com/kevinthedang/discord-ollama) (Generalized TypeScript Discord Bot w/ Tuning Documentation)
+- [Discord AI chat/moderation bot](https://github.com/rapmd73/Companion) Chat/moderation bot written in python. Uses Ollama to create personalities.
 
 ### Supported backends 
 - [llama.cpp](https://github.com/ggerganov/llama.cpp) project founded by Georgi Gerganov.