helloadhavan/github_issues huggingface dataset:
Repository: vercel/next.js
Pull request: Disable `dynamicIO` in global default cache handler test

To prepare for an upcoming change where `ppr` will be enabled automatically when `dynamicIO` is enabled, we're disabling `dynamicIO` in the global default cache handler test, and using the `useCache` config instead, because `output: 'standalone'` is currently not compatible with PPR.

Changed files:
filename: test/ppr-tests-manifest.json
patch: @@ -103,7 +103,8 @@
       "test/e2e/app-dir/segment-cache/prefetch-scheduling/prefetch-scheduling.test.ts",
       "test/e2e/app-dir/segment-cache/revalidation/segment-cache-revalidation.test.ts",
       "test/e2e/app-dir/segment-cache/staleness/segment-cache-stale-time.test.ts",
-      "test/production/app-dir/build-output-tree-view/build-output-tree-view.test.ts"
+      "test/production/app-dir/build-output-tree-view/build-output-tree-view.test.ts",
+      "test/production/app-dir/global-default-cache-handler/global-default-cache-handler.test.ts"
     ]
   }
 }

filename: test/production/app-dir/global-default-cache-handler/app/page.tsx
patch: @@ -1,5 +1,6 @@
 import React, { Suspense } from 'react'
 import { revalidate } from './actions'
+import { connection } from 'next/server'
 
 async function Random({ cached }: { cached?: boolean }) {
   const data = await fetch(
@@ -22,7 +23,9 @@ async function CachedRandom() {
   return <Random cached />
 }
 
-export default function Page() {
+export default async function Page() {
+  await connection()
+
   return (
     <>
       <p>index page</p>

filename: test/production/app-dir/global-default-cache-handler/global-default-cache-handler.test.ts
patch: @@ -8,16 +8,12 @@ import {
   retry,
 } from 'next-test-utils'
 
-describe('dynamic-io-cache-handlers', () => {
+describe('global-default-cache-handler', () => {
   let appPort: number
   let server: any
   let output = ''
   let next: NextInstance
 
-  if (process.env.__NEXT_EXPERIMENTAL_PPR) {
-    return it('should skip', () => {})
-  }
-
   beforeAll(async () => {
     next = await createNext({
       files: new FileRef(__dirname),

filename: test/production/app-dir/global-default-cache-handler/next.config.js
patch: @@ -4,7 +4,7 @@
 const nextConfig = {
   output: 'standalone',
   experimental: {
-    dynamicIO: true,
+    useCache: true,
   },
 }
Repository: nodejs/node
Pull request: test: set `test-fs-cp` as flaky

Refs: https://github.com/nodejs/node/issues/56794

Changed files:
filename: test/parallel/parallel.status
patch: @@ -27,6 +27,8 @@ test-native-certs-macos: SKIP
 test-async-context-frame: PASS, FLAKY
 # https://github.com/nodejs/node/issues/54534
 test-runner-run-watch: PASS, FLAKY
+# https://github.com/nodejs/node/issues/56794
+test-fs-cp: PASS, FLAKY
 
 # https://github.com/nodejs/node/issues/56751
 test-without-async-context-frame: PASS, FLAKY
Repository: huggingface/transformers
Pull request: Fix auto batch size finder test

`--auto_find_batch_size 0` has to be the last test argument because later the test does `testargs[-1] = "1"` :)

Changed files:
filename: tests/trainer/test_trainer.py
patch: @@ -3300,8 +3300,8 @@ def test_auto_batch_size_finder(self):
                 --learning_rate 2e-5
                 --num_train_epochs 1
                 --output_dir {tmpdir}
-                --auto_find_batch_size 0
                 --report_to none
+                --auto_find_batch_size 0
                 """.split()
             with self.assertRaises(RuntimeError):
                 with patch.object(sys, "argv", testargs):
Repository: ggml-org/llama.cpp
Pull request: llama : allow building all tests on windows when not using shared libs

The current condition is unnecessarily strict, when building without shared libraries (`BUILD_SHARED_LIBS=OFF`) the tests can still be built on windows.

Changed files:
filename: .github/workflows/build.yml
patch: @@ -687,8 +687,8 @@ jobs:
     strategy:
       matrix:
         include:
-          - build: 'cpu-x64'
-            defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF'
+          - build: 'cpu-x64 (static)'
+            defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF'
           - build: 'openblas-x64'
             defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
           - build: 'vulkan-x64'

filename: tests/CMakeLists.txt
patch: @@ -104,8 +104,8 @@ if (LLAMA_LLGUIDANCE)
     llama_build_and_test(test-grammar-llguidance.cpp ARGS ${CMAKE_CURRENT_SOURCE_DIR}/../models/ggml-vocab-llama-bpe.gguf)
 endif ()
 
-if (NOT WIN32)
-    # these tests are disabled on Windows because they use internal functions not exported with LLAMA_API
+if (NOT WIN32 OR NOT BUILD_SHARED_LIBS)
+    # these tests are disabled on Windows because they use internal functions not exported with LLAMA_API (when building with shared libraries)
     llama_build_and_test(test-sampling.cpp)
     llama_build_and_test(test-grammar-parser.cpp)
     llama_build_and_test(test-grammar-integration.cpp)

filename: tests/test-chat.cpp
patch: @@ -7,6 +7,8 @@
 //
 #include "chat.h"
 
+#include "log.h"
+
 #include "../src/unicode.h"
 #include "../src/llama-grammar.h"
 
@@ -1428,6 +1430,8 @@ static void test_msg_diffs_compute() {
 }
 
 int main(int argc, char ** argv) {
+    common_log_set_verbosity_thold(999);
+
     // try {
 #ifndef _WIN32
         if (argc > 1) {
Repository: denoland/deno
Pull request: test: disable 'test-child-process-ipc-next-tick.js' Node compat test

This test is super flaky recently.

See https://github.com/denoland/deno/issues/25855 for more details.

Changed files:
filename: tests/node_compat/config.jsonc
patch: @@ -43,7 +43,9 @@
       // TODO(littledivy): windows ipc streams not yet implemented
       "test-child-process-fork-ref.js",
       "test-child-process-fork-ref2.js",
-      "test-child-process-ipc-next-tick.js",
+      // TODO(bartlomieju): this test is very flaky on CI
+      // https://github.com/denoland/deno/issues/25855
+      // "test-child-process-ipc-next-tick.js",
       "test-child-process-ipc.js",
       "test-child-process-spawnsync-env.js",
       "test-child-process-stdio-inherit.js",

filename: tests/node_compat/test/parallel/test-child-process-ipc-next-tick.js
patch: @@ -1,52 +0,0 @@
-// deno-fmt-ignore-file
-// deno-lint-ignore-file
-
-// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 18.12.1
-// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
-
-'use strict';
-
-// Ignore on Windows.
-if (process.platform === 'win32') {
-  process.exit(0);
-}
-
-const common = require('../common');
-const assert = require('assert');
-const cp = require('child_process');
-const NUM_MESSAGES = 10;
-const values = [];
-
-for (let i = 0; i < NUM_MESSAGES; ++i) {
-  values[i] = i;
-}
-
-if (process.argv[2] === 'child') {
-  const received = values.map(() => { return false; });
-
-  process.on('uncaughtException', common.mustCall((err) => {
-    received[err] = true;
-    const done = received.every((element) => { return element === true; });
-
-    if (done)
-      process.disconnect();
-  }, NUM_MESSAGES));
-
-  process.on('message', (msg) => {
-    // If messages are handled synchronously, throwing should break the IPC
-    // message processing.
-    throw msg;
-  });
-
-  process.send('ready');
-} else {
-  const child = cp.fork(__filename, ['child']);
-
-  child.on('message', common.mustCall((msg) => {
-    assert.strictEqual(msg, 'ready');
-    values.forEach((value) => {
-      child.send(value);
-    });
-  }));
-}
Repository: electron/electron
Pull request: fix: -Wunsafe-buffer-usage warnings in ElectronAccessibilityUI ctor

Backport of #44055

See that PR for details.


Notes: none.

Changed files:
filename: shell/browser/ui/webui/accessibility_ui.cc
patch: @@ -359,8 +359,7 @@ ElectronAccessibilityUI::ElectronAccessibilityUI(content::WebUI* web_ui)
 
   // Add required resources.
   html_source->UseStringsJs();
-  html_source->AddResourcePaths(
-      base::make_span(kAccessibilityResources, kAccessibilityResourcesSize));
+  html_source->AddResourcePaths(kAccessibilityResources);
   html_source->SetDefaultResource(IDR_ACCESSIBILITY_ACCESSIBILITY_HTML);
   html_source->SetRequestFilter(
       base::BindRepeating(&ShouldHandleAccessibilityRequestCallback),
Repository: denoland/deno
Pull request: v2.0.0-rc.5


Changed files:
filename: Cargo.lock
patch: @@ -1146,7 +1146,7 @@ dependencies = [
 
 [[package]]
 name = "deno"
-version = "2.0.0-rc.4"
+version = "2.0.0-rc.5"
 dependencies = [
  "anstream",
  "async-trait",

filename: cli/Cargo.toml
patch: @@ -2,7 +2,7 @@
 
 [package]
 name = "deno"
-version = "2.0.0-rc.4"
+version = "2.0.0-rc.5"
 authors.workspace = true
 default-run = "deno"
 edition.workspace = true
Repository: nodejs/node
Pull request: inspector: fix GN build

Fix the GN build after recent roll and movement of `inspector_protocol`.

Changed files:
filename: src/inspector/unofficial.gni
patch: @@ -13,7 +13,7 @@ template("inspector_gn_build") {
   }
 
   node_gen_dir = get_label_info("../..", "target_gen_dir")
-  protocol_tool_path = "../../tools/inspector_protocol"
+  protocol_tool_path = "../../deps/inspector_protocol"
 
   gypi_values = exec_script(
       "../../tools/gypi_to_gn.py",
@@ -35,6 +35,8 @@ template("inspector_gn_build") {
     ]
 
     args = [
+      "--inspector_protocol_dir",
+      rebase_path(protocol_tool_path, root_build_dir),
       "--jinja_dir",
       # jinja is in third_party.
       rebase_path("//third_party/", root_build_dir),
@@ -72,4 +74,37 @@ template("inspector_gn_build") {
     outputs = [ "$node_gen_dir/src/{{source_name_part}}.json" ]
     args = [ "{{source}}" ] + rebase_path(outputs, root_build_dir)
   }
+
+  config("crdtp_config") {
+    include_dirs = [ protocol_tool_path ]
+  }
+
+  static_library("crdtp") {
+    public_configs = [ ":crdtp_config" ]
+    sources = [
+      "$protocol_tool_path/crdtp/cbor.cc",
+      "$protocol_tool_path/crdtp/cbor.h",
+      "$protocol_tool_path/crdtp/dispatch.cc",
+      "$protocol_tool_path/crdtp/dispatch.h",
+      "$protocol_tool_path/crdtp/error_support.cc",
+      "$protocol_tool_path/crdtp/error_support.h",
+      "$protocol_tool_path/crdtp/export.h",
+      "$protocol_tool_path/crdtp/find_by_first.h",
+      "$protocol_tool_path/crdtp/frontend_channel.h",
+      "$protocol_tool_path/crdtp/glue.h",
+      "$protocol_tool_path/crdtp/json.cc",
+      "$protocol_tool_path/crdtp/json.h",
+      "$protocol_tool_path/crdtp/parser_handler.h",
+      "$protocol_tool_path/crdtp/protocol_core.cc",
+      "$protocol_tool_path/crdtp/protocol_core.h",
+      "$protocol_tool_path/crdtp/serializable.cc",
+      "$protocol_tool_path/crdtp/serializable.h",
+      "$protocol_tool_path/crdtp/span.cc",
+      "$protocol_tool_path/crdtp/span.h",
+      "$protocol_tool_path/crdtp/status.cc",
+      "$protocol_tool_path/crdtp/status.h",
+      "$protocol_tool_path/crdtp/json_platform.cc",
+      "$protocol_tool_path/crdtp/json_platform.h",
+    ]
+  }
 }

filename: unofficial.gni
patch: @@ -190,6 +190,7 @@ template("node_gn_build") {
     }
     if (node_enable_inspector) {
       deps += [
+        "src/inspector:crdtp",
         "src/inspector:node_protocol_generated_sources",
         "src/inspector:v8_inspector_compress_protocol_json",
       ]
Repository: denoland/deno
Pull request: fix: better error for Deno.UnsafeWindowSurface, correct HttpClient name, cleanup unused code


Changed files:
filename: cli/main.rs
patch: @@ -385,6 +385,13 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
         FixSuggestion::info("window global is not available in Deno 2."),
         FixSuggestion::hint("Replace `window` with `globalThis`."),
       ];
+    } else if msg.contains("UnsafeWindowSurface is not a constructor") {
+      return vec![
+        FixSuggestion::info("Deno.UnsafeWindowSurface is an unstable API."),
+        FixSuggestion::hint(
+          "Run again with `--unstable-webgpu` flag to enable this API.",
+        ),
+      ];
     }
   }
 

filename: cli/tsc/dts/lib.deno.ns.d.ts
patch: @@ -6041,9 +6041,11 @@ declare namespace Deno {
    *
    * @category Fetch
    */
-  export interface HttpClient extends Disposable {
+  export class HttpClient implements Disposable {
     /** Close the HTTP client. */
     close(): void;
+
+    [Symbol.dispose](): void;
   }
 
   /**

filename: runtime/js/90_deno_ns.js
patch: @@ -132,7 +132,7 @@ const denoNs = {
   UnsafePointerView: ffi.UnsafePointerView,
   UnsafeFnPointer: ffi.UnsafeFnPointer,
   umask: fs.umask,
-  httpClient: httpClient.httpClient,
+  HttpClient: httpClient.HttpClient,
   createHttpClient: httpClient.createHttpClient,
 };
 
@@ -160,15 +160,6 @@ denoNsUnstableById[unstableIds.cron] = {
   cron: cron.cron,
 };
 
-denoNsUnstableById[unstableIds.ffi] = {};
-
-denoNsUnstableById[unstableIds.fs] = {};
-
-denoNsUnstableById[unstableIds.http] = {
-  HttpClient: httpClient.HttpClient,
-  createHttpClient: httpClient.createHttpClient,
-};
-
 denoNsUnstableById[unstableIds.kv] = {
   openKv: kv.openKv,
   AtomicOperation: kv.AtomicOperation,

filename: runtime/lib.rs
patch: @@ -122,8 +122,8 @@ pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
   },
   UnstableGranularFlag {
     name: deno_webgpu::UNSTABLE_FEATURE_NAME,
-    help_text: "Enable unstable `WebGPU` API",
-    show_in_help: false,
+    help_text: "Enable unstable `WebGPU` APIs",
+    show_in_help: true,
     id: 11,
   },
   UnstableGranularFlag {

filename: tests/unit/fetch_test.ts
patch: @@ -1156,6 +1156,7 @@ Deno.test(
   > {
     const caCert = Deno.readTextFileSync("tests/testdata/tls/RootCA.pem");
     const client = Deno.createHttpClient({ caCerts: [caCert] });
+    assert(client instanceof Deno.HttpClient);
     const response = await fetch("https://localhost:5545/assets/fixture.json", {
       client,
     });
Repository: vercel/next.js
Pull request: Update Turbopack production test manifest

This auto-generated PR updates the production integration test manifest used when testing Turbopack.

Changed files:
filename: test/turbopack-build-tests-manifest.json
patch: @@ -3292,6 +3292,13 @@
     "flakey": [],
     "runtimeError": false
   },
+  "test/e2e/app-dir/monaco-editor/monaco-editor.test.ts": {
+    "passed": ["monaco-editor should load monaco-editor"],
+    "failed": [],
+    "pending": [],
+    "flakey": [],
+    "runtimeError": false
+  },
   "test/e2e/app-dir/navigation-layout-suspense/navigation-layout-suspense.test.ts": {
     "passed": [
       "app dir - navigation with Suspense in nested layout resolves data after client navigation to a nested layout with Suspense"
@@ -4185,12 +4192,11 @@
       "ppr-full Dynamic RSC Response for /on-demand/c should have correct headers",
       "ppr-full Dynamic RSC Response for /static should have correct headers",
       "ppr-full Dynamic RSC Response for /static should not contain dynamic content",
-      "ppr-full HTML Fallback Dynamic Shell should render the dynamic shell as static if the page is static",
+      "ppr-full HTML Fallback Dynamic Shell should render the fallback shell even if the page is static",
+      "ppr-full HTML Fallback Dynamic Shell should render the fallback shell every time",
       "ppr-full HTML Fallback Dynamic Shell should render the fallback shell on first visit",
-      "ppr-full HTML Fallback Dynamic Shell should render the route shell on the second visit",
       "ppr-full HTML Fallback Dynamic Shell will allow dynamic fallback shells even when static is enforced",
-      "ppr-full HTML Fallback Dynamic Shell will only revalidate the page",
-      "ppr-full HTML Fallback Dynamic Shell will revalidate the page and fallback shell",
+      "ppr-full HTML Fallback Dynamic Shell will not revalidate the fallback shell",
       "ppr-full HTML Fallback for /fallback/nested/params/slug-01/slug-02 should render the fallback HTML immediately",
       "ppr-full HTML Fallback for /fallback/nested/use-params/slug-01/slug-02 should render the fallback HTML immediately",
       "ppr-full HTML Fallback for /fallback/nested/use-pathname/slug-01/slug-02 should render the fallback HTML immediately",
Repository: electron/electron
Pull request: fix: -Wunsafe-buffer-usage warnings in ElectronAccessibilityUI ctor

#### Description of Change

Part 12 in a [series](https://github.com/electron/electron/pull/43477) to fix `-Wunsafe-buffer-usage` warnings in `shell/`.

Both part 11 and 12 today are pretty easy.  This one's similar to https://github.com/electron/electron/pull/44024: upstream declares the length of some kConstantArray, which means that array is Spannable. We can pass it directly to functions taking a span argument and don't need to use the unsafe version of `make_span()`.

For example,`gen/chrome/grit/accessibility_resources_map.h` has these declarations:

```c++
extern const webui::ResourcePath AccessibilityResources[3];
extern const size_t kAccessibilityResourcesSize;
```

So we can change our code:

```diff
- FunctionThatTakesASpanArg(std::make_span(kAccessibilityResources, kAccessibilityResourcesSize));
+ FunctionThatTakesASpanArg(kAccessibilityResources);
```

Fixed by this PR:

```
../../electron/shell/browser/ui/webui/accessibility_ui.cc:363:7: error: function introduces unsafe buffer manipulation [-Werror,-Wunsafe-buffer-usage]
  363 |       base::make_span(kAccessibilityResources, kAccessibilityResourcesSize));
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../electron/shell/browser/ui/webui/accessibility_ui.cc:363:7: note: See //docs/unsafe_buffers.md for help.
```

#### 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: none.

Changed files:
filename: shell/browser/ui/webui/accessibility_ui.cc
patch: @@ -359,8 +359,7 @@ ElectronAccessibilityUI::ElectronAccessibilityUI(content::WebUI* web_ui)
 
   // Add required resources.
   html_source->UseStringsJs();
-  html_source->AddResourcePaths(
-      base::make_span(kAccessibilityResources, kAccessibilityResourcesSize));
+  html_source->AddResourcePaths(kAccessibilityResources);
   html_source->SetDefaultResource(IDR_ACCESSIBILITY_ACCESSIBILITY_HTML);
   html_source->SetRequestFilter(
       base::BindRepeating(&ShouldHandleAccessibilityRequestCallback),
Repository: denoland/deno
Pull request: perf(ext/fetch): improve decompression throughput by upgrading `tower_http`

Fixes #25798

This accomplishes the same result as #25800, but not by manually implementing a decompression logic, but by upgrading `tower-http` to incorporate the patch (https://github.com/tower-rs/tower-http/pull/521).

![performance comparison](https://github.com/user-attachments/assets/e008c47c-87f7-4a42-8c27-2eae7e7f659c)


Changed files:
filename: Cargo.lock
patch: @@ -7541,9 +7541,9 @@ dependencies = [
 
 [[package]]
 name = "tower-http"
-version = "0.5.2"
+version = "0.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
+checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97"
 dependencies = [
  "async-compression",
  "bitflags 2.6.0",
@@ -7561,9 +7561,9 @@ dependencies = [
 
 [[package]]
 name = "tower-layer"
-version = "0.3.2"
+version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
 
 [[package]]
 name = "tower-service"

filename: Cargo.toml
patch: @@ -185,7 +185,7 @@ tokio-rustls = { version = "0.26.0", default-features = false, features = ["ring
 tokio-socks = "0.5.1"
 tokio-util = "0.7.4"
 tower = { version = "0.4.13", default-features = false, features = ["util"] }
-tower-http = { version = "0.5.2", features = ["decompression-br", "decompression-gzip"] }
+tower-http = { version = "0.6.1", features = ["decompression-br", "decompression-gzip"] }
 tower-lsp = { package = "deno_tower_lsp", version = "0.1.0", features = ["proposed"] }
 tower-service = "0.3.2"
 twox-hash = "=1.6.3"
Repository: denoland/deno
Pull request: fix: error out if a valid flag is passed before a subcommand

Closes #25808

Changed files:
filename: cli/args/flags.rs
patch: @@ -1233,6 +1233,51 @@ pub fn flags_from_vec(args: Vec<OsString>) -> clap::error::Result<Flags> {
   }
 
   if let Some((subcommand, mut m)) = matches.remove_subcommand() {
+    let pre_subcommand_arg = app
+      .get_arguments()
+      .filter(|arg| !arg.is_global_set())
+      .find(|arg| {
+        matches
+          .value_source(arg.get_id().as_str())
+          .is_some_and(|value| value == clap::parser::ValueSource::CommandLine)
+      })
+      .map(|arg| {
+        format!(
+          "--{}",
+          arg.get_long().unwrap_or_else(|| arg.get_id().as_str())
+        )
+      });
+
+    if let Some(arg) = pre_subcommand_arg {
+      let usage = app.find_subcommand_mut(&subcommand).unwrap().render_usage();
+
+      let mut err =
+        clap::error::Error::new(ErrorKind::UnknownArgument).with_cmd(&app);
+      err.insert(
+        clap::error::ContextKind::InvalidArg,
+        clap::error::ContextValue::String(arg.clone()),
+      );
+
+      let valid = app.get_styles().get_valid();
+
+      let styled_suggestion = clap::builder::StyledStr::from(format!(
+        "'{}{subcommand} {arg}{}' exists",
+        valid.render(),
+        valid.render_reset()
+      ));
+
+      err.insert(
+        clap::error::ContextKind::Suggested,
+        clap::error::ContextValue::StyledStrs(vec![styled_suggestion]),
+      );
+      err.insert(
+        clap::error::ContextKind::Usage,
+        clap::error::ContextValue::StyledStr(usage),
+      );
+
+      return Err(err);
+    }
+
     match subcommand.as_str() {
       "add" => add_parse(&mut flags, &mut m),
       "remove" => remove_parse(&mut flags, &mut m),
@@ -4695,16 +4740,10 @@ fn run_parse(
       "[SCRIPT_ARG] may only be omitted with --v8-flags=--help, else to use the repl with arguments, please use the `deno repl` subcommand",
     ));
   } else {
-    return Err(
-      app
-        .get_subcommands_mut()
-        .find(|subcommand| subcommand.get_name() == "run")
-        .unwrap()
-        .error(
-          clap::error::ErrorKind::MissingRequiredArgument,
-          "[SCRIPT_ARG] may only be omitted with --v8-flags=--help",
-        ),
-    );
+    return Err(app.find_subcommand_mut("run").unwrap().error(
+      clap::error::ErrorKind::MissingRequiredArgument,
+      "[SCRIPT_ARG] may only be omitted with --v8-flags=--help",
+    ));
   }
 
   Ok(())
@@ -10799,4 +10838,17 @@ mod tests {
       }
     )
   }
+
+  #[test]
+  fn flag_before_subcommand() {
+    let r = flags_from_vec(svec!["deno", "--allow-net", "repl"]);
+    assert_eq!(
+      r.unwrap_err().to_string(),
+      "error: unexpected argument '--allow-net' found
+
+  tip: 'repl --allow-net' exists
+
+Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
+    )
+  }
 }