cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.69k stars 3.16k forks source link

intercept cannot includes __cypress/assets path #29764

Open gweesin opened 2 months ago

gweesin commented 2 months ago

Current behavior

It doesn't work when intercepting path includes __cypress/assets

Desired behavior

Could be intercepted successfully:

cy.intercept('**/assets/data.json', { fixture: 'example.json' })

fetch('/__cypress/assets/data.json')

Test code to reproduce

https://github.com/gweesin/cypress-intercept-assets-bug

Cypress Version

13.12.0

Node version

22.3.0

Operating System

Windows 11.22631.3737

Debug Logs

cypress:server:automation:cookies received get:cookies [] +2ms
  cypress:server:socket-base automation:request clear:cookies [] +3ms
  cypress:server:automation:cookies clear:cookies 0 +1ms
  cypress:server:socket-base backend:request { eventName: 'reset:rendered:html:origins', args: [] } +2ms
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1719496885660-4', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +5ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1719496885660-4', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +54ms
  cypress:server:fixture fixture exact name exists D:\person\issue-demo\cypress-intercept-assets-bug\cypress\fixtures\example.json +56ms
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1719496885671-5', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +10ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1719496885671-5', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +11ms
  cypress:server:fixture fixture exact name exists D:\person\issue-demo\cypress-intercept-assets-bug\cypress\fixtures\example.json +9ms
GET /__cypress/assets/data.json 404 0.953 ms - 136
  cypress:proxy:http:util:prerequests Never received pre-request or url without pre-request for request GET-https://content-autofill.googleapis.com/v1/pages/ChVDaHJvbWUvMTI2LjAuNjQ3OC4xMjcSIAkyWoxKH6I8mBIFDTec3tMSBQ2RYZVOIajlTCMyfr-B?alt=proto after waiting 2000ms. Continuing without one. +6s
  cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: null, domain: 'content-autofill', tld: 'googleapis.com' } +602ms
  cypress:server:remote-states getting remote state: undefined for: https://content-autofill.googleapis.com/v1/pages/ChVDaHJvbWUvMTI2LjAuNjQ3OC4xMjcSIAkyWoxKH6I8mBIFDTec3tMSBQ2RYZVOIajlTCMyfr-B?alt=proto +575ms
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +0ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +0ms
  cypress:server:stream_buffer stream buffer writeable final called +6s
  cypress:network:agent addRequest called { isHttps: true, href: 'https://content-autofill.googleapis.com/v1/pages/ChVDaHJvbWUvMTI2LjAuNjQ3OC4xMjcSIAkyWoxKH6I8mBIFDTec3tMSBQ2RYZVOIajlTCMyfr-B?alt=proto' } +6s
  cypress:network:agent got family { family: undefined, href: 'https://content-autofill.googleapis.com/v1/pages/ChVDaHJvbWUvMTI2LjAuNjQ3OC4xMjcSIAkyWoxKH6I8mBIFDTec3tMSBQ2RYZVOIajlTCMyfr-B?alt=proto' } +0ms
  cypress:server:server-base Got CONNECT request from optimizationguide-pa.googleapis.com:443 +5s
  cypress:https-proxy Writing browserSocket connection headers { url: 'optimizationguide-pa.googleapis.com:443', headLength: 0, headers: { host: 'optimizationguide-pa.google
apis.com:443', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' } } +5s
  cypress:https-proxy Got first head bytes { url: 'optimizationguide-pa.googleapis.com:443', head: '\x16\x03\x01\x06�\x01\x00\x06�\x03\x03�j���ޑ��1�Dr�ZȊ[�\x15��\x19��p�-�Z�� \x07{\r�O���ּwho���䃛\x1AI:\x13�\x13' } +1ms
  cypress:https-proxy Making intercepted connection to 3974 +1ms
  cypress:network:connect successfully connected { opts: { port: 3974, host: 'localhost', getDelayMsForRetry: [Function: h] }, iteration: 0 } +5s
  cypress:https-proxy received upstreamSocket callback for request { port: 3974, hostname: 'localhost', err: undefined } +1ms
  cypress:server:util:socket_allowed allowing socket { localPort: 4198 } +2s
  cypress:launcher:browsers chrome stderr: [48532:32824:0627/220126.651:ERROR:cert_verify_proc_builtin.cc(1051)] CertVerifyProcBuiltin for optimizationguide-pa.googleapis.com failed:
----- Certificate i=0 (OU=Cypress Proxy Server Certificate,O=Cypress Proxy CA,L=Internet,ST=Internet,C=Internet,CN=optimizationguide-pa.googleapis.com) -----
ERROR: No matching issuer found +5s
  cypress:server:request received status code & headers on request { requestId: 'request11', statusCode: 200, headers: { 'content-type': 'text/plain' } } +6s
  cypress:server:request successful response received { requestId: 'request11' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/v1/pages/ChVDaHJvbWUvMTI2LjAuNjQ3OC4xMjcSIAkyWoxKH6I8mBIFDTec3tMSBQ2RYZVOIajlTCMyfr-B?alt=proto' }, request: undefined } +1s
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +455ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +455ms
  cypress:server:remote-states getting primary remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } +0ms
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +0ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +0ms
GET /v1/pages/ChVDaHJvbWUvMTI2LjAuNjQ3OC4xMjcSIAkyWoxKH6I8mBIFDTec3tMSBQ2RYZVOIajlTCMyfr-B?alt=proto 200 2465.178 ms - -
  cypress:server:server-base Got CONNECT request from optimizationguide-pa.googleapis.com:443 +248ms
  cypress:https-proxy Writing browserSocket connection headers { url: 'optimizationguide-pa.googleapis.com:443', headLength: 0, headers: { host: 'optimizationguide-pa.google
apis.com:443', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' } } +246ms
  cypress:https-proxy Got first head bytes { url: 'optimizationguide-pa.googleapis.com:443', head: '\x16\x03\x01\x06�\x01\x00\x06�\x03\x03\x1DK���5��CP�^�<V���Te��~�"\r��\x02\x0F(" ���Q\x16C�\x11W���Q�YV>��\x02' } +0ms
  cypress:https-proxy Making intercepted connection to 3974 +0ms
  cypress:network:connect successfully connected { opts: { port: 3974, host: 'localhost', getDelayMsForRetry: [Function: h] }, iteration: 0 } +247ms
  cypress:https-proxy received upstreamSocket callback for request { port: 3974, hostname: 'localhost', err: undefined } +1ms
  cypress:server:util:socket_allowed allowing socket { localPort: 4200 } +248ms
  cypress:proxy:http:util:prerequests Never received pre-request or url without pre-request for request POST-https://optimizationguide-pa.googleapis.com/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw after waiting 2000ms. Continuing without one. +2s
  cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: null, domain: 'optimizationguide-pa', tld: 'googleapis.com' } +2s
  cypress:server:remote-states getting remote state: undefined for: https://optimizationguide-pa.googleapis.com/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw +2s 
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +1ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +1ms
  cypress:server:stream_buffer appending chunk to buffer { bytesWritten: 0, chunkLength: 908 } +2s
  cypress:network:agent addRequest called { isHttps: true, href: 'https://optimizationguide-pa.googleapis.com/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw' } +2s
  cypress:network:agent got family { family: undefined, href: 'https://optimizationguide-pa.googleapis.com/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw' } +0ms  
  cypress:network:agent Creating proxied socket for https://optimizationguide-pa.googleapis.com/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw through http://127.0.0.1:33210 +1ms
  cypress:server:stream_buffer stream buffer writeable final called +1ms
  cypress:network:connect successfully connected { opts: { port: 33210, host: '127.0.0.1', useTls: false, getDelayMsForRetry: [Function (anonymous)] }, iteration: 0 } +2s   
  cypress:network:agent Proxy socket for https://optimizationguide-pa.googleapis.com/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw established +1ms
  cypress:server:request received status code & headers on request { requestId: 'request12', statusCode: 200, headers: { 'content-type': 'application/x-protobuf' } } +2s
  cypress:server:request successful response received { requestId: 'request12' } +1ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw' }, request: undefined } +2s     
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +357ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +357ms
  cypress:server:remote-states getting primary remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } +0ms
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +0ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +0ms
POST /v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw 200 2363.864 ms - -
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
  cypress:server:util:process_profiler ┌─────────┬───────────┬──────────────┬─────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
  cypress:server:util:process_profiler │ (index) │   group   │ processCount │                  pids                   │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
  cypress:server:util:process_profiler ├─────────┼───────────┼──────────────┼─────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
  cypress:server:util:process_profiler │    0    │ 'Chrome'  │      6       │ '48532, 28996, 50264, 5596, 2480, 3592' │    1.43    │      0.71      │  646.38  │    457.35    │   646.38    │
  cypress:server:util:process_profiler │    1    │ 'cypress' │      1       │                 '28400'                 │    0.06    │      0.05      │  402.42  │    394.12    │   402.42    │
  cypress:server:util:process_profiler │    2    │  'other'  │      5       │   '5768, 49844, 39640, 35192, 31388'    │    0.14    │      0.74      │  370.14  │    415.43    │   486.35    │
  cypress:server:util:process_profiler │    3    │ 'plugin'  │      2       │             '30912, 22368'              │    0.18    │      0.06      │  136.67  │    86.49     │   136.67    │
  cypress:server:util:process_profiler │    4    │  'TOTAL'  │      14      │                   '-'                   │    1.8     │      1.33      │ 1555.61  │   1200.93    │   1555.61   │
  cypress:server:util:process_profiler └─────────┴───────────┴──────────────┴─────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘ +12s
  cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 4066 } +5s
  cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 4198 } +2s
  cypress:server:socket-e2e watch:test:file { id: 'U3BlYzpEOi9wZXJzb24vaXNzdWUtZGVtby9jeXByZXNzLWludGVyY2VwdC1hc3NldHMtYnVnL2N5cHJlc3MvZTJlL3NwZWMuY3kuanM=', name: 'spec.cy.
js', specType: 'integration', absolute: 'D:/person/issue-demo/cypress-intercept-assets-bug/cypress/e2e/spec.cy.js', baseName: 'spec.cy.js', fileName: 'spec', specFileExtension: '.cy.js', fileExtension: '.js', relative: 'cypress\\e2e\\spec.cy.js' } +13s
  cypress:server:socket-e2e watching spec with config { id: 'U3BlYzpEOi9wZXJzb24vaXNzdWUtZGVtby9jeXByZXNzLWludGVyY2VwdC1hc3NldHMtYnVnL2N5cHJlc3MvZTJlL3NwZWMuY3kuanM=', name:
 'spec.cy.js', specType: 'integration', absolute: 'D:/person/issue-demo/cypress-intercept-assets-bug/cypress/e2e/spec.cy.js', baseName: 'spec.cy.js', fileName: 'spec', specFileExtension: '.cy.js', fileExtension: '.js', relative: 'cypress\\e2e\\spec.cy.js' } +0ms
  cypress:server:iframes handling iframe for project spec { spec: { name: '', absolute: '', relative: '', specType: 'integration' }, extraOptions: { specType: 'integration' } } +12s
  cypress:server:controllers handle iframe { test: 'cypress\\e2e\\spec.cy.js', specFilter: undefined } +12s
  cypress:server:controllers get specs { spec: 'cypress\\e2e\\spec.cy.js', extraOptions: { specType: 'integration' } } +0ms
  cypress:server:controllers normalizing spec { spec: 'cypress\\e2e\\spec.cy.js' } +0ms
  cypress:server:controllers converted cypress\e2e\spec.cy.js to D:\person\issue-demo\cypress-intercept-assets-bug\cypress\e2e\spec.cy.js +0ms
  cypress:server:controllers test url for file { file: 'cypress\\e2e\\spec.cy.js', url: '/__cypress/tests?p=cypress\\e2e\\spec.cy.js' } +0ms
  cypress:server:controllers test url for file { file: 'cypress\\support\\e2e.js', url: '/__cypress/tests?p=cypress\\support\\e2e.js' } +0ms
  cypress:server:controllers all files to send [ 'cypress\\support\\e2e.js', 'cypress\\e2e\\spec.cy.js' ] +0ms
  cypress:server:remote-states getting primary remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } +8s
  cypress:server:controllers iframe cypress\e2e\spec.cy.js options { superDomain: 'localhost', title: 'cypress\\e2e\\spec.cy.js', scripts: '[{"absolute":"D:\\\\person\\\\iss
ue-demo\\\\cypress-intercept-assets-bug\\\\cypress\\\\support\\\\e2e.js","relative":"cypress\\\\support\\\\e2e.js","relativeUrl":"/__cypress/tests?p=cypress\\\\support\\\\e2
e.js"},{"absolute":"D:\\\\person\\\\issue-demo\\\\cypress-intercept-assets-bug\\\\cypress\\\\e2e\\\\spec.cy.js","relative":"cypress\\\\e2e\\\\spec.cy.js","relativeUrl":"/__c
ypress/tests?p=cypress\\\\e2e\\\\spec.cy.js"}]', privilegedChannel: '/* global window */\r\n' + '(({ browserFamily, isSpecBridge, key, namespace, scripts, url, win = window 
}) => {\r\n' + '  /**\r\n' + '   * This file is read as a string in the server and injected into the spec\r\n' + '   * frame in order to create a privileged channel between 
the server and\r\n' + '   * the spec frame. The values above are provided by the server, with the\r\n' + '   * `key` being particularly important since it is used to validat
e\r\n' + '   * any messages sent from this channel back to the server.\r\n' + '   *\r\n' + '   * This file does not get preprocessed, so it should not contain syntax that\r\
n' + '   * our minimum supported browsers do not support.\r\n' + '   */\r\n' + '\r\n' + '  const Err = win.Error\r\n' + '  const captureStackTrace = win.Error.captureStackTr
ace\r\n' + '  const filter = win.Array.prototype.filter\r\n' + '  const arrayIncludes = win.Array.prototype.includes\r\n' + '  const map = win.Array.prototype.map\r\n' + '  
const slice = win.Array.prototype.slice\r\n' + '  const isArray = win.Array.isArray\r\n' + '  const stringIncludes = win.String.prototype.includes\r\n' + '  const replace = 
win.String.prototype.replace\r\n' + '  const split = win.String.prototype.split\r\n' + '  const functionToString = win.Function.prototype.toString\r\n' + '  const fetch = wi
n.fetch\r\n' + '  const parse = win.JSON.parse\r\n' + '  const stringify = win.JSON.stringify\r\n' + '  const charCodeAt = win.String.prototype.charCodeAt\r\n' + '  const im
ul = Math.imul\r\n' + '\r\n' + '  const queryStringRegex = /\\?.*$/\r\n' + '\r\n' + '  let hasValidCallbackContext = false\r\n' + '\r\n' + "  // since this function is eval'
d, the scripts are included as stringified JSON\r\n" + '  if (scripts) {\r\n' + '    scripts = parse(scripts)\r\n' + '  }\r\n' + '\r\n' + '  // when privileged commands are 
called within the cy.origin() callback,\r\n' + "  // since the callback is eval'd in the spec bridge instead of being run\r\n" + '  // directly in the spec frame, we need to
 use different criteria, namely\r\n' + '  // that the stack includes the function where we eval the callback\r\n' + '  const hasSpecBridgeInvocation = (err) => {\r\n' + '   
 switch (browserFamily) {\r\n' + "      case 'chromium':\r\n" + "        return stringIncludes.call(err.stack, 'at invokeOriginFn')\r\n" + "      case 'firefox':\r\n" + "   
     return stringIncludes.call(err.stack, 'invokeOriginFn@')\r\n" + "      // currently, this won't run in webkit since it doesn't\r\n" + '      // support cy.origin()\r\n'
 + '      default:\r\n' + '        return false\r\n' + '    }\r\n' + '  }\r\n' + '\r\n' + '  // in chromium, stacks only include lines from the frame where the error is\r\n'
 + '  // created, so to validate a function call was from the spec frame, we strip\r\n' + '  // message lines and any eval calls (since they could be invoked from outside\r\
n' + '  // the spec frame) and if there are lines left, they must have been from\r\n' + '  // the spec frame itself\r\n' + '  const hasSpecFrameStackLines = (err) => {\r\n' 
+ "    const stackLines = split.call(err.stack, '\\n')\r\n" + '    const filteredLines = filter.call(stackLines, (line) => {\r\n' + '      return (\r\n' + '        !stringIn
cludes.call(line, err.message)\r\n' + "        && !stringIncludes.call(line, 'eval at <anonymous>')\r\n" + '      )\r\n' + '    })\r\n' + '\r\n' + '    return filteredLines.
length > 0\r\n' + '  }\r\n' + '\r\n' + '  const isInCallback = (err) => {\r\n' + "    return stringIncludes.call(err.stack, 'thenFn@') || stringIncludes.call(err.stack, 'wit
hinFn@')\r\n" + '  }\r\n' + '\r\n' + '  const hasCallbackInsideEval = (err) => {\r\n' + "    if (browserFamily === 'webkit') {\r\n" + '      return isInCallback(err) && hasV
alidCallbackContext\r\n' + '    }\r\n' + '\r\n' + "    return isInCallback(err) && stringIncludes.call(err.stack, '> eval line')\r\n" + '  }\r\n' + '\r\n' + '  // in non-chr
omium browsers, the stack will include either the spec file url\r\n' + '  // or the support file\r\n' + '  const hasStackLinesFromSpecOrSupportFile = (err) => {\r\n' + '    
return filter.call(scripts, (script) => {\r\n' + '      // in webkit, stack line might not include the query string\r\n' + "      if (browserFamily === 'webkit') {\r\n" + " 
       script = replace.call(script, queryStringRegex, '')\r\n" + '      }\r\n' + '\r\n' + '      return stringIncludes.call(err.stack, script)\r\n' + '    }).length > 0\r\n
' + '  }\r\n' + '\r\n' + '  // privileged commands are commands that should only be called from the spec\r\n' + '  // because they escape the browser sandbox and (generally)
 have access to node\r\n' + '  const privilegedCommands = [\r\n' + "    'exec',\r\n" + "    // cy.origin() doesn't directly access node, but is a pathway for other\r\n" + ' 
   // commands to do so\r\n' + "    'origin',\r\n" + "    'readFile',\r\n" + '    // cy.selectFile() accesses node when using the path argument to read a file\r\n' + "    's
electFile',\r\n" + "    'writeFile',\r\n" + "    'task',\r\n" + '  ]\r\n' + '\r\n' + '  const callbackCommands = [\r\n' + "    'each',\r\n" + "    'then',\r\n" + "    'withi
n',\r\n" + '  ]\r\n' + '\r\n' + '  function stackIsFromSpecFrame (err) {\r\n' + '    if (isSpecBridge) {\r\n' + '      return hasSpecBridgeInvocation(err)\r\n' + '    }\r\n'
 + '\r\n' + "    if (browserFamily === 'chromium') {\r\n" + '      return hasStackLinesFromSpecOrSupportFile(err) || hasSpecFrameStackLines(err)\r\n' + '    }\r\n' + '\r\n' 
+ '    return hasCallbackInsideEval(err) || hasStackLinesFromSpecOrSupportFile(err)\r\n' + '  }\r\n' + '\r\n' + '  // source: https://github.com/bryc/code/blob/d0dac1c607a00
5679799024ff66166e13601d397/jshash/experimental/cyrb53.js\r\n' + '  function hash (str) {\r\n' + '    const seed = 0\r\n' + '    let h1 = 0xdeadbeef ^ seed\r\n' + '    let h
2 = 0x41c6ce57 ^ seed\r\n' + '\r\n' + '    for (let i = 0, ch; i < str.length; i++) {\r\n' + '      ch = charCodeAt.call(str, i)\r\n' + '      h1 = imul(h1 ^ ch, 2654435761)
\r\n' + '      h2 = imul(h2 ^ ch, 1597334677)\r\n' + '    }\r\n' + '    h1 = imul(h1 ^ (h1 >>> 16), 2246822507)\r\n' + '    h1 ^= imul(h2 ^ (h2 >>> 13), 3266489909)\r\n' + '
    h2 = imul(h2 ^ (h2 >>> 16), 2246822507)\r\n' + '    h2 ^= imul(h1 ^ (h1 >>> 13), 3266489909)\r\n' + '\r\n' + '    return `${4294967296 * (2097151 & h2) + (h1 >>> 0)}`\r\
n' + '  }\r\n' + '\r\n' + '  // removes trailing undefined args\r\n' + '  function dropRightUndefined (array) {\r\n' + '    if (!isArray(array)) return []\r\n' + '\r\n' + ' 
   let index = array.length\r\n' + '\r\n' + '    // find index of last non-undefined arg\r\n' + '    // eslint-disable-next-line no-empty\r\n' + '    while (index-- && array
[index] === undefined) {}\r\n' + '\r\n' + '    return slice.call(array, 0, index + 1)\r\n' + '  }\r\n' + '\r\n' + '  function onCommandInvocation (command) {\r\n' + "    // 
message doesn't really matter since we're only interested in the stack\r\n" + "    const err = new Err('command stack error')\r\n" + '\r\n' + '    // strips the stack for th
is function itself, so we get a more accurate\r\n' + '    // look at where the command was called from\r\n' + '    if (captureStackTrace) {\r\n' + '      captureStackTrace.c
all(Err, err, onCommandInvocation)\r\n' + '    }\r\n' + '\r\n' + '    if (arrayIncludes.call(callbackCommands, command.name)) {\r\n' + '      hasValidCallbackContext = stack
IsFromSpecFrame(err)\r\n' + '    }\r\n' + '\r\n' + '    if (!arrayIncludes.call(privilegedCommands, command.name)) return\r\n' + '\r\n' + "    // if stack is not validated a
s being from the spec frame, don't add\r\n" + '    // it as a verified command\r\n' + '    if (!stackIsFromSpecFrame(err)) return\r\n' + '\r\n' + '    // hash the args to av
oid `413 Request Entity Too Large` error from express.\r\n' + '    // see https://github.com/cypress-io/cypress/issues/27099 and\r\n' + '    // https://github.com/cypress-io
/cypress/issues/27097\r\n' + '    const args = map.call(dropRightUndefined([...(command.args || [])]), (arg) => {\r\n' + '      if (arg === undefined) {\r\n' + '        arg 
= null\r\n' + '      }\r\n' + '\r\n' + "      if (typeof arg === 'function') {\r\n" + '        arg = functionToString.call(arg)\r\n' + '      }\r\n' + '\r\n' + '      return
 hash(stringify(arg))\r\n' + '    })\r\n' + '\r\n' + '    // if we verify a privileged command was invoked from the spec frame, we\r\n' + "    // send it to the server, wher
e it's stored in state. when the command is\r\n" + '    // run and it sends its message to the server via websocket, we check\r\n' + '    // that verified status before allo
wing the command to continue running\r\n' + '    //\r\n' + '    // needs to use the fully-qualified url or else when the baseUrl includes\r\n' + '    // basic auth, the fetc
h fails with a security error\r\n' + '    // see https://github.com/cypress-io/cypress/issues/28336\r\n' + '    const promise = fetch(`${win.location.origin}/${namespace}/ad
d-verified-command`, {\r\n' + '      body: stringify({\r\n' + '        args,\r\n' + '        name: command.name,\r\n' + '        key,\r\n' + '        url,\r\n' + '      }),\
r\n' + '      headers: {\r\n' + "        'Content-Type': 'application/json',\r\n" + '      },\r\n' + "      method: 'POST',\r\n" + '    }).catch(() => {\r\n' + "      // thi
s erroring is unlikely, but it's fine to ignore. if adding the\r\n" + '      // verified command failed, the default behavior is NOT to allow\r\n' + '      // the privileged
 command to run\r\n' + '    })\r\n' + '\r\n' + '    return {\r\n' + '      args,\r\n' + '      promise,\r\n' + '    }\r\n' + '  }\r\n' + '\r\n' + "  win.Cypress.on('command:
invocation', onCommandInvocation)\r\n" + '\r\n' + '  // returned for testing purposes only\r\n' + '  return {\r\n' + '    dropRightUndefined,\r\n' + '    onCommandInvocation
,\r\n' + '  }\r\n' + '})\r\n' + '({\n' + "      browserFamily: 'chromium',\n" + '      isSpecBridge: false,\n' + "      key: '6b3d951b-2910-48d0-81c3-860ec259f134',\n" + "  
    namespace: '__cypress',\n" + `      scripts: '["/__cypress/tests?p=cypress\\\\\\\\support\\\\\\\\e2e.js","/__cypress/tests?p=cypress\\\\\\\\e2e\\\\\\\\spec.cy.js"]',\n` + "      url: 'http://localhost:3972/__cypress/iframes/cypress%5Ce2e%5Cspec.cy.js?browserFamily=chromium'\n" + '    })' } +2ms
GET /__cypress/iframes/cypress%5Ce2e%5Cspec.cy.js?browserFamily=chromium 200 3.677 ms - -
  cypress:server:controllers:spec request for { spec: 'cypress\\support\\e2e.js' } +11s
  cypress:server:preprocessor getting file cypress\support\e2e.js +12s
  cypress:server:preprocessor getFile D:\person\issue-demo\cypress-intercept-assets-bug\cypress\support\e2e.js +0ms
  cypress:lifecycle:EventRegistrar execute plugin event 'file:preprocessor' Node 'v18.17.1' with args: EventEmitter { _events: [Object: null prototype] { rerun: [Function (a
nonymous)] }, _eventsCount: 1, _maxListeners: undefined, filePath: 'D:\\person\\issue-demo\\cypress-intercept-assets-bug\\cypress\\support\\e2e.js', shouldWatch: true, outpu
tPath: 'C:\\Users\\86159\\AppData\\Roaming\\Cypress\\cy\\production\\projects\\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\\bundles\\cypress\\support\\e2e.js', [Symbol(kCapture)]: false } undefined undefined +12s
  cypress:lifecycle:ProjectConfigManager call event file:preprocessor for invocation id inv13 +11s
  cypress:lifecycle:child:RunPlugins:30912 execute plugin event: file:preprocessor ({ invocationId: 'inv13', eventId: 3 }) +12s
  cypress:webpack user options: { webpackOptions: { mode: 'development', node: { global: true, __filename: true, __dirname: true }, module: { rules: [Array] }, plugins: [ [P
rovidePlugin], [LimitChunkCountPlugin], [LimitChunkCountPlugin] ], resolve: { extensions: [Array], fallback: [Object], plugins: [] }, entry: [ 'D:\\person\\issue-demo\\cypre
ss-intercept-assets-bug\\cypress\\support\\e2e.js' ], output: { publicPath: '', path: 'C:\\Users\\86159\\AppData\\Roaming\\Cypress\\cy\\production\\projects\\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\\bundles\\cypress\\support', filename: 'e2e.js' }, devtool: 'inline-source-map' } } +11s
  cypress:webpack get D:\person\issue-demo\cypress-intercept-assets-bug\cypress\support\e2e.js +1ms
  cypress:webpack already have bundle for D:\person\issue-demo\cypress-intercept-assets-bug\cypress\support\e2e.js +0ms
  cypress:lifecycle:ProjectConfigManager promise resolved for id 'inv13' with value C:\Users\86159\AppData\Roaming\Cypress\cy\production\projects\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\bundles\cypress\support\e2e.js +2ms
  cypress:server:controllers:spec sending spec { filePath: 'C:\\Users\\86159\\AppData\\Roaming\\Cypress\\cy\\production\\projects\\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\\bundles\\cypress\\support\\e2e.js' } +2ms
GET /__cypress/tests?p=cypress\support\e2e.js 200 2.976 ms - -
  cypress:server:controllers:spec request for { spec: 'cypress\\e2e\\spec.cy.js' } +2ms
  cypress:server:preprocessor getting file cypress\e2e\spec.cy.js +4ms
  cypress:server:preprocessor getFile D:\person\issue-demo\cypress-intercept-assets-bug\cypress\e2e\spec.cy.js +0ms
  cypress:lifecycle:EventRegistrar execute plugin event 'file:preprocessor' Node 'v18.17.1' with args: EventEmitter { _events: [Object: null prototype] { rerun: [Function (a
nonymous)] }, _eventsCount: 1, _maxListeners: undefined, filePath: 'D:\\person\\issue-demo\\cypress-intercept-assets-bug\\cypress\\e2e\\spec.cy.js', shouldWatch: true, outpu
tPath: 'C:\\Users\\86159\\AppData\\Roaming\\Cypress\\cy\\production\\projects\\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\\bundles\\cypress\\e2e\\spec.cy.js', [Symbol(kCapture)]: false } undefined undefined +4ms
  cypress:lifecycle:ProjectConfigManager call event file:preprocessor for invocation id inv14 +2ms
  cypress:lifecycle:child:RunPlugins:30912 execute plugin event: file:preprocessor ({ invocationId: 'inv14', eventId: 3 }) +4ms
  cypress:webpack user options: { webpackOptions: { mode: 'development', node: { global: true, __filename: true, __dirname: true }, module: { rules: [Array] }, plugins: [ [P
rovidePlugin], [LimitChunkCountPlugin], [LimitChunkCountPlugin] ], resolve: { extensions: [Array], fallback: [Object], plugins: [] }, entry: [ 'D:\\person\\issue-demo\\cypre
ss-intercept-assets-bug\\cypress\\support\\e2e.js' ], output: { publicPath: '', path: 'C:\\Users\\86159\\AppData\\Roaming\\Cypress\\cy\\production\\projects\\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\\bundles\\cypress\\support', filename: 'e2e.js' }, devtool: 'inline-source-map' } } +3ms
  cypress:webpack get D:\person\issue-demo\cypress-intercept-assets-bug\cypress\e2e\spec.cy.js +0ms
  cypress:webpack already have bundle for D:\person\issue-demo\cypress-intercept-assets-bug\cypress\e2e\spec.cy.js +0ms
  cypress:lifecycle:ProjectConfigManager promise resolved for id 'inv14' with value C:\Users\86159\AppData\Roaming\Cypress\cy\production\projects\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\bundles\cypress\e2e\spec.cy.js +1ms
  cypress:server:controllers:spec sending spec { filePath: 'C:\\Users\\86159\\AppData\\Roaming\\Cypress\\cy\\production\\projects\\cypress-intercept-assets-bug-862071f384222cbf5e32174e0559ac77\\bundles\\cypress\\e2e\\spec.cy.js' } +1ms
GET /__cypress/tests?p=cypress\e2e\spec.cy.js 200 1.852 ms - -
  cypress:server:socket-base backend:request { eventName: 'close:extra:targets', args: [] } +11s
  cypress:server:browsers getBrowserLauncher { browser: { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '126.0.6478.127', path: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', minSupportedVersion: 64, majorVersion: '126', isHeaded: true, isHeadless: false } } +11s
  cypress:server:socket-base backend:request { eventName: 'reset:server:state', args: [] } +0ms
  cypress:proxy:http:util:buffers resetting buffers +11s
  cypress:server:remote-states resetting remote state +34ms
  cypress:server:socket-base backend:request { eventName: 'get:rendered:html:origins', args: [] } +1ms
  cypress:server:socket-base automation:request get:cookies {} +0ms
  cypress:server:automation:cookies getting:cookies {} +11s
  cypress:server:automation:cookies received get:cookies [] +1ms
  cypress:server:socket-base automation:request clear:cookies [] +5ms
  cypress:server:automation:cookies clear:cookies 0 +4ms
  cypress:server:socket-base backend:request { eventName: 'reset:rendered:html:origins', args: [] } +1ms
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1719496896761-7', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +12ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1719496896761-7', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +11s
  cypress:server:fixture fixture exact name exists D:\person\issue-demo\cypress-intercept-assets-bug\cypress\fixtures\example.json +11s
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1719496896774-8', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +11ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1719496896774-8', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +10ms
  cypress:server:fixture fixture exact name exists D:\person\issue-demo\cypress-intercept-assets-bug\cypress\fixtures\example.json +13ms
  cypress:net-stubbing:server:util sending event to driver { eventName: 'before:request', data: { eventId: 'event16', subscription: { eventName: 'before:request', await: fal
se, routeId: '1719496896761-7' }, browserRequestId: '3592.120', requestId: 'interceptedRequest15', data: { headers: [Object], url: 'http://localhost:3972/__cypress/asset/data.json', method: 'GET', httpVersion: '1.1', resourceType: 'fetch', query: {}, body: '' } } } +11s
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: 'http://localhost:3972/__cypress/asset/data.json' }, request: d { subscriptionsByRoute: [ [O
bject] ], includeBodyInAfterResponse: false, responseSent: true, onResponse: [Function (anonymous)], id: 'interceptedRequest15', req: IncomingMessage { _readableState: [Read
ableState], _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, socket: [Socket], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', 
complete: true, rawHeaders: [Array], rawTrailers: [], joinDuplicateHeaders: undefined, aborted: false, upgrade: false, url: 'http://localhost:3972/__cypress/asset/data.json'
, method: 'GET', statusCode: null, statusMessage: null, client: [Socket], _consuming: false, _dumped: false, proxiedUrl: 'http://localhost:3972/__cypress/asset/data.json', n
ext: [Function: y], baseUrl: '', originalUrl: '/__cypress/asset/data.json', _parsedUrl: [Url], params: [Object], query: {}, res: [ServerResponse], secret: undefined, cookies
: [Object], signedCookies: [Object: null prototype] {}, _startAt: [Array], _startTime: 2024-06-27T14:01:36.792Z, _remoteAddress: '127.0.0.1', route: [p], isAUTFrame: false, 
isFromExtraTarget: false, browserPreRequest: [Object], noPreRequestExpected: false, resourceType: 'fetch', matchingRoutes: [Array], requestId: 'interceptedRequest15', body: 
'', [Symbol(kCapture)]: false, [Symbol(kHeaders)]: [Object], [Symbol(kHeadersCount)]: 28, [Symbol(kTrailers)]: null, [Symbol(kTrailersCount)]: 0 }, res: ServerResponse { _ev
ents: [Object: null prototype], _eventsCount: 3, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: false, chunkedEncoding: fa
lse, shouldKeepAlive: true, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: true, _removedConnection: false, _re
movedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: null, _hasBody: true, _trailer: '', finished: false, _headerSent: false, _closed: false, 
socket: [Socket], _header: null, _keepAliveTimeout: 5000, _onPendingData: [Function: bound updateOutgoingData], req: [IncomingMessage], _sent100: false, _expect_continue: fa
lse, _maxRequestsPerSocket: 0, locals: [Object: null prototype] {}, flush: [Function (anonymous)], write: [Function (anonymous)], end: [Function (anonymous)], on: [Function 
(anonymous)], writeHead: [Function (anonymous)], _startAt: undefined, _startTime: undefined, __onFinished: [Function], body: '{"name":"Using fixtures to represent data","ema
il":"hello@cypress.io","body":"Fixtures are a great way to mock data for responses to routes"}', [Symbol(kCapture)]: false, [Symbol(kBytesWritten)]: 0, [Symbol(kNeedDrain)]:
 false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: null, [Symbol(errored)]: null, [Symbol(kHighWaterMark)]: 16384, [Symbol(kRejectNonStandardBodyWrites)]: false, [Symbol(kU
niqueHeaders)]: null }, continueRequest: [Function: next], onError: [Function: _], _onResponse: [Function: onResponse], state: { requests: [Object], routes: [Array], pending
EventHandlers: {}, reset: [Function: reset] }, socket: p { ensureProp: [Function: i], inRunMode: false, supportsRunEvents: false, ended: false, localBus: [EventEmitter], onT
estFileChange: [Function: bound ], testFilePath: 'cypress\\e2e\\spec.cy.js', onStudioTestFileChange: [Function: bound onStudioTestFileChange], removeOnStudioTestFileChange: 
[Function: bound removeOnStudioTestFileChange], _socketIo: [u], _cdpIo: [m], _sendResetBrowserTabsForNextSpecMessage: [AsyncFunction (anonymous)], _sendResetBrowserStateMess
age: [AsyncFunction (anonymous)], _sendFocusBrowserMessage: [AsyncFunction (anonymous)], _isRunnerSocketConnected: [Function (anonymous)] }, lastEvent: 'before:request' } } +8s
  cypress:net-stubbing:server:util sending event to driver { eventName: 'response:callback', data: { eventId: 'event17', subscription: { eventName: 'response:callback', awai
t: false, routeId: '1719496896761-7' }, browserRequestId: '3592.120', requestId: 'interceptedRequest15', data: { headers: [Object], body: '{"name":"Using fixtures to represe
nt data","email":"hello@cypress.io","body":"Fixtures are a great way to mock data for responses to routes"}', url: 'http://localhost:3972/__cypress/asset/data.json', method:
 null, httpVersion: null, statusCode: 200, statusMessage: null } } } +2ms
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +8s
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +52ms
  cypress:server:remote-states getting primary remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } +0ms
  cypress:network:cors Parsed URL { port: '3972', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } +1ms
  cypress:server:remote-states getting remote state: { auth: undefined, origin: 'http://localhost:3972', strategy: 'file', fileServer: 'http://localhost:3973', domainName: 'localhost', props: null } for: http://localhost:3972 +1ms
GET /__cypress/asset/data.json 200 7.554 ms - -
  cypress:net-stubbing:server:util sending event to driver { eventName: 'after:response', data: { eventId: 'event18', subscription: { eventName: 'after:response', await: false, routeId: '1719496896761-7' }, browserRequestId: '3592.120', requestId: 'interceptedRequest15', data: {} } } +4ms
  cypress:server:socket-base backend:request { eventName: 'close:extra:targets', args: [] } +57ms
  cypress:server:browsers getBrowserLauncher { browser: { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '126.0.6478.127', path: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', minSupportedVersion: 64, majorVersion: '126', isHeaded: true, isHeadless: false } } +87ms
  cypress:server:socket-base backend:request { eventName: 'reset:server:state', args: [] } +1ms
  cypress:proxy:http:util:buffers resetting buffers +88ms
  cypress:server:remote-states resetting remote state +35ms
  cypress:server:socket-base backend:request { eventName: 'get:rendered:html:origins', args: [] } +0ms
  cypress:server:socket-base automation:request get:cookies {} +0ms
  cypress:server:automation:cookies getting:cookies {} +82ms
  cypress:server:automation:cookies received get:cookies [] +7ms
  cypress:server:socket-base automation:request clear:cookies [] +11ms
  cypress:server:automation:cookies clear:cookies 0 +4ms
  cypress:server:socket-base backend:request { eventName: 'reset:rendered:html:origins', args: [] } +8ms
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1719496896858-9', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +6ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1719496896858-9', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +83ms
  cypress:server:fixture fixture exact name exists D:\person\issue-demo\cypress-intercept-assets-bug\cypress\fixtures\example.json +81ms
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1719496896870-10', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +11ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1719496896870-10', hasInterceptor: false, routeMatcher: [Object], staticResponse: [Object] } ] } +11ms
  cypress:server:fixture fixture exact name exists D:\person\issue-demo\cypress-intercept-assets-bug\cypress\fixtures\example.json +11ms
GET /__cypress/assets/data.json 404 4.185 ms - 136

Other

No response

mauroaccornero commented 2 months ago

just my 2 cents but It looks like it's a desired behaviour fix: update net stubbing to not intercept requests sent to dev server

or maybe related to the server

server/lib/routes.ts

gweesin commented 2 months ago

just my 2 cents but It looks like it's a desired behaviour fix: update net stubbing to not intercept requests sent to dev server

or maybe related to the server

server/lib/routes.ts

I also tried and it looks like the server/lib/routes.ts intercept __cypress/assets in order to load static assets file.