microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.19k stars 29.29k forks source link

Incorrect response when using port forwarding #206948

Closed yakisova41 closed 7 months ago

yakisova41 commented 8 months ago

Type: Bug

const express = require("express");

const app = express();

/**
 * If this variable is set to ture, base64 text is added to the response.
As a result, the response will not be returned correctly.

Setting it to false will add "a" with the same number of characters as the base64.
However, the response will be returned correctly.

 */
const isbase64 = true;

const icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAADL1JREFUeJztnXtsVFUexz93mAJtsFChtTy1UgRBqlhqgqihPggBCbtmfbCuCoi7fxglRhYwyvpK3OAbHzHiYmQTVoEFdtWIPFUUUXC7vJt1eSlQYctTKGVaOr/942x3pnPvPO+r7ZxPcpLOnDPn/ub+vvM7555XDREhbQzDAAYDlcAtwBXpV+I4Apz02wiPOQ2sB9YBXyPSmG4FRsoCMIwgMBq4B7gZ6JHuxTSu8jOwGlgK/DVVMSQXgHL8b4EngJ72bNR4xA/ADEQWJyuYWACG0Q/4CzDSMdM0XvIxcB8ix+MViC8Aw7gcWIv+1bd19gO/QGSrVaa1AAxjMMr5xW5apvGMk8B4RL6KzQiYihrGEFSvUju//dANWIlh3Bib0TICGMZFQBXQyzPTNF7yH+BKRA43vxGJAIbRAdXh085vvxQB86PfiG4CHgVMIULT7hiLYdzT/EI1AYZxIbAX6OqfXRoPOQqUIHKmOQJMRjs/m+gB3AeRJmCyf7ZofOLXAIZAKfBvn43ReE8Y6BUAxvtticYXAsCIAHqcP5u5JgD089sKjW8M1gLIbgYYohYSXOC3JRpfqA8AOX5bofGNTgEg6LcVGv8IAh38NkITQ0EBXHQRnDoFR45AOOzapQKA4VrtmtQZORLmz4faWjh+HKqroaYG6uthxQqYNAmCLgRrAdHJx1RUJLJsmaREdbXIDTc4ef0mLQA/0+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h8wM5TwAuItJPjPbOXTCPAEdRyY00bJ1MBPG61yUDT9shEANuA95w3ReMHmQjg94g48F+LNa2BdDuBKxBZ5ZYxGu9JJwI0ATNctEXjA+lEgD8hssNNYzTek+oZQaeBp1y0Q+MTqTYBf0TksNvGaLwnlSbgIDDXA1s0PpBKBJgV73ABTdsnmQD+CbzvkS0aH0gmgOmxhwpp2heJBLAckXVeGqPxnnidwEZglse2aHwgXgR4C5HvvTZG4z1WAjgJPOODLRofsBKAPtUji4gVwD7gTZ9s0fhAbCdQn+qRZURHgG+ApT7aovGBZgHoUz2ylGYBLEJEH+aYhQRQZ8s+4bchGn8wBCoR+cxvQzT+8F/HY9h040De8wAAAABJRU5ErkJggg==";
const notBase64 = "a".repeat(icon.length + 1);

const text = `// ==UserScript==
// @name Return YouTube Comment Username
// @name:ja YouTubeコメント欄の名前を元に戻す
// @name:zh-CN 恢復 YouTube 评论用户名
// @name:zh-TW 恢復 YouTube 評論名稱
// @version 0.4.1
// @author yakisova41
// @license MIT
// @icon ${isbase64 ? icon : notBase64}
// @namespace https://yt-returnname-api.pages.dev/extension/
// @description This script replaces the "handle" in the YouTube comments section to user name
// @description:ja YouTubeのコメント欄の名前をハンドル(@...)からユーザー名に書き換えます。
// @description:zh-TW 此腳本將 YouTube 評論部分中的“handle”替換為用戶名
// @description:zh-CN 此脚本将 YouTube 评论部分中的“handle”替换为用户名
// @match https://www.youtube.com/*
// @grant unsafeWindow
// @run-at document-end
// ==/UserScript==
const socket = new WebSocket("ws://localhost:5174");
  socket.onmessage = (event) => {
      switch (event.data) {
          case "reload":
              console.log("[ts-extension-builder] hotreload");
              window.location.reload();
              break;
          case "connect":
              console.log(
                  "[ts-extension-builder] hotreload server connected"
              );
              break;
      }
  };

import("http://localhost:5173/script").then(module => {
  const args = {}
  if(GM_info.script.grant !== undefined){
    GM_info.script.grant.forEach(propatyName => {
      let keyName = propatyName.split("GM_")[1];

      if(keyName === "xmlhttpRequest"){
          keyName = "xmlHttpRequest"
      }
      args[propatyName] = GM[keyName]
    })
  }
  module.default(args)
})`

app.get("/", (req, res) => {
    res.set({ "Content-Type": "application/javascript charset=UTF-8" });
    res.write(text);
    res.end();
});

const port = 5173;
const host = "localhost";
app.listen(port, host,  () => {
    console.log(`http://localhost:${port}`);
});

This problem may be only in my environment, If you run this code in nodejs over ssh, listen to the express server, and then access that server as localhost from a client using port forwarding, the text in the returned file will be missing.

Replacing this base64 with a of the same number of characters will allow correct access.

This bug did not occur in 1.85.2

スクリーンショット 2024-03-06 190114

VS Code version: Code 1.87.0 (019f4d1419fbc8219a181fab7892ebccf7ee29a2, 2024-02-27T23:41:44.469Z) OS version: Windows_NT x64 10.0.22621 Modes: Remote OS version: Linux x64 5.15.0-97-generic

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 5 5600 6-Core Processor (12 x 3500)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.93GB (7.61GB free)| |Process Argv|--crash-reporter-id 1e889686-6b74-41ea-ae83-cc78ba1aeb12| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: 192.168.1.22| |OS|Linux x64 5.15.0-97-generic| |CPUs|Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz (4 x 1600)| |Memory (System)|15.50GB (12.24GB free)| |VM|0%|
Extensions (55) Extension|Author (truncated)|Version ---|---|--- browse-lite|ant|0.3.8 postcss|css|1.0.9 php-types|Ern|1.1.0 better-cpp-syntax|jef|1.17.2 jupyter-keymap|ms-|1.1.2 remote-containers|ms-|0.348.0 remote-ssh|ms-|0.109.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.86.0 vscode-remote-extensionpack|ms-|0.25.0 remote-explorer|ms-|0.4.3 remote-server|ms-|1.5.1 commit-message-editor|ada|0.25.0 vscode-zipfs|arc|3.0.0 markdown-yaml-preamble|bie|0.1.0 vscode-tailwindcss|bra|0.10.5 doxdocgen|csc|1.4.0 dart-code|Dar|3.84.0 flutter|Dar|3.84.0 vscode-eslint|dba|2.4.4 prettier-vscode|esb|9.14.0 vscode-github-actions|git|0.26.2 go|gol|0.41.1 rest-client|hum|0.25.1 better-cpp-syntax|jef|1.17.2 json-to-ts|Mar|1.7.5 git-graph|mhu|1.30.0 vscode-docker|ms-|1.29.0 vscode-language-pack-ja|MS-|1.87.2024030609 debugpy|ms-|2024.2.0 isort|ms-|2023.10.1 python|ms-|2024.2.1 vscode-pylance|ms-|2024.2.3 jupyter|ms-|2024.2.0 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.17 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 cmake-tools|ms-|1.17.17 cpptools|ms-|1.19.5 cpptools-extension-pack|ms-|1.3.0 hexeditor|ms-|1.9.14 codic|piz|0.1.0 vscode-css-peek|pra|4.4.1 vscode-yaml|red|1.14.0 LiveServer|rit|5.7.9 rust-analyzer|rus|0.4.1870 vs-code-prettier-eslint|rve|6.0.0 gitmoji-vscode|sea|1.2.5 tauri-vscode|tau|0.2.6 cmake|twx|0.0.17 vscode-choosealicense|ult|0.9.4 php-debug|xde|1.34.0 php-pack|xde|1.0.3 php-intellisense|zob|1.3.3 (2 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:30968133 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:30979542 d34g3935:30971562 a89i1917:30973842 bg6jg535:30979843 8f97e687:30977000 dsvsc020:30976470 ```
alexr00 commented 7 months ago

I'm not sure what could be causing this.

@yakisova41 did you figure out what was going on?

yakisova41 commented 7 months ago

Rebooting cured it... At least it didn't seem to be a vscode bug.