Skip to content

Commit b593217

Browse files
committed
upd
1 parent ce88f1e commit b593217

1 file changed

Lines changed: 0 additions & 90 deletions

File tree

public/console-capture.js

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -53,94 +53,4 @@
5353

5454
// Log that capture is active
5555
console.log('[Console Capture] Initialized successfully');
56-
57-
// Debug: Check if Vitest browser globals are set
58-
console.log('[Debug] window.__vitest_browser_runner__:', typeof window.__vitest_browser_runner__, window.__vitest_browser_runner__);
59-
60-
// Intercept XMLHttpRequest to log headers for __vitest_api__ requests
61-
// const OriginalXMLHttpRequest = window.XMLHttpRequest;
62-
// window.XMLHttpRequest = function() {
63-
// const xhr = new OriginalXMLHttpRequest();
64-
// const originalOpen = xhr.open;
65-
// const originalSetRequestHeader = xhr.setRequestHeader;
66-
// const originalSend = xhr.send;
67-
68-
// let requestUrl = '';
69-
// let requestMethod = '';
70-
// const requestHeaders = {};
71-
72-
// xhr.open = function(method, url, ...args) {
73-
// requestUrl = url;
74-
// requestMethod = method;
75-
// if (url.includes('__vitest_api__')) {
76-
// console.log('[XHR BROWSER] Opening request:', method, url);
77-
// }
78-
// return originalOpen.apply(this, [method, url, ...args]);
79-
// };
80-
81-
// xhr.setRequestHeader = function(header, value) {
82-
// requestHeaders[header] = value;
83-
// if (requestUrl.includes('__vitest_api__')) {
84-
// console.log('[XHR BROWSER] Setting header:', header, '=', value);
85-
// }
86-
// return originalSetRequestHeader.apply(this, arguments);
87-
// };
88-
89-
// xhr.send = function(...args) {
90-
// if (requestUrl.includes('__vitest_api__')) {
91-
// console.log('[XHR BROWSER] Sending request to:', requestUrl);
92-
// console.log('[XHR BROWSER] All request headers:', JSON.stringify(requestHeaders, null, 2));
93-
// }
94-
// return originalSend.apply(this, args);
95-
// };
96-
97-
// return xhr;
98-
// };
99-
100-
// Intercept fetch API to log headers for __vitest_api__ requests
101-
// const originalFetch = window.fetch;
102-
// window.fetch = function(url, options) {
103-
// if (url.includes && url.includes('__vitest_api__')) {
104-
// console.log('[FETCH BROWSER] Request URL:', url);
105-
// console.log('[FETCH BROWSER] Request options:', JSON.stringify(options, null, 2));
106-
// if (options && options.headers) {
107-
// console.log('[FETCH BROWSER] Request headers:', JSON.stringify(options.headers, null, 2));
108-
// }
109-
// }
110-
// return originalFetch.apply(this, arguments);
111-
// };
112-
113-
// Intercept WebSocket constructor to log connection attempts and status changes
114-
const OriginalWebSocket = window.WebSocket;
115-
window.WebSocket = function(url, protocols) {
116-
// Log the connection request with full URL including protocol
117-
const fullUrl = url.startsWith('ws://') || url.startsWith('wss://')
118-
? url
119-
: (window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + url;
120-
121-
console.log('[WebSocket] Connecting to:', fullUrl);
122-
123-
try {
124-
const ws = new OriginalWebSocket(url, protocols);
125-
126-
// Log connection status change events
127-
ws.addEventListener('open', () => {
128-
console.log('[WebSocket] Connection OPENED:', fullUrl);
129-
});
130-
131-
ws.addEventListener('error', () => {
132-
console.log('[WebSocket] Connection ERROR:', fullUrl);
133-
});
134-
135-
ws.addEventListener('close', (event) => {
136-
console.log('[WebSocket] Connection CLOSED:', fullUrl, '- Code:', event.code, '- Reason:', event.reason || '(none)');
137-
});
138-
139-
return ws;
140-
} catch (error) {
141-
console.error('[WebSocket] Failed to create connection:', fullUrl, error);
142-
throw error;
143-
}
144-
};
145-
window.WebSocket.prototype = OriginalWebSocket.prototype;
14656
})();

0 commit comments

Comments
 (0)