Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/McpContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import fs from 'node:fs/promises';
import fsPromises from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
Expand Down Expand Up @@ -788,7 +787,7 @@ export class McpContext implements Context {
const filepath = await getTempFilePath(filename);
await this.validatePath(filepath);
try {
await fs.writeFile(filepath, data);
await fsPromises.writeFile(filepath, data);
} catch (err) {
throw new Error('Could not save a file', {cause: err});
}
Expand All @@ -806,8 +805,8 @@ export class McpContext implements Context {
path.resolve(clientProvidedFilePath),
extension,
);
await fs.mkdir(path.dirname(filePath), {recursive: true});
await fs.writeFile(filePath, data);
await fsPromises.mkdir(path.dirname(filePath), {recursive: true});
await fsPromises.writeFile(filePath, data);
return {filename: filePath};
} catch (err) {
this.logger?.(err);
Expand Down
5 changes: 1 addition & 4 deletions src/PageCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class PageEventSubscriber {
inspectorIssue,
)[0];
if (!issue) {
logger?.('No issue mapping for for the issue: ', inspectorIssue.code);
logger?.('No issue mapping for the issue: ', inspectorIssue.code);
return;
}

Expand Down Expand Up @@ -375,9 +375,6 @@ export class NetworkCollector extends PageCollector<HTTPRequest> {
}
override splitAfterNavigation(page: Page) {
const navigations = this.storage.get(page) ?? [];
if (!navigations) {
Comment thread
Lightning00Blade marked this conversation as resolved.
return;
}

const requests = navigations[0];

Expand Down
4 changes: 2 additions & 2 deletions src/WaitForHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class WaitForHelper {
}

const navigationFinished = this.waitForNavigationStarted()
.then(navigationStated => {
if (navigationStated) {
.then(navigationStarted => {
if (navigationStarted) {
return this.#page.waitForNavigation({
timeout: options?.timeout ?? this.#navigationTimeout,
signal: this.#abortController.signal,
Expand Down
16 changes: 8 additions & 8 deletions src/formatters/NetworkFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class NetworkFormatter {
}

toStringDetailed(): string {
return converNetworkRequestDetailedToStringDetailed(this.toJSONDetailed());
return convertNetworkRequestDetailedToStringDetailed(this.toJSONDetailed());
}

toJSON(): NetworkRequestConcise {
Expand Down Expand Up @@ -233,13 +233,13 @@ export class NetworkFormatter {
const responseBuffer = await httpResponse.buffer();

if (isUtf8(responseBuffer)) {
const responseAsTest = responseBuffer.toString('utf-8');
const responseAsText = responseBuffer.toString('utf-8');

if (responseAsTest.length === 0) {
if (responseAsText.length === 0) {
return '<empty response>';
}

return getSizeLimitedString(responseAsTest, sizeLimit);
return getSizeLimitedString(responseAsText, sizeLimit);
}

return '<binary data>';
Expand All @@ -263,22 +263,22 @@ function convertNetworkRequestConciseToString(
return `reqid=${data.requestId} ${data.method} ${data.url} [${data.status}]${data.selectedInDevToolsUI ? ` [selected in the DevTools Network panel]` : ''}`;
}

function formatHeadlers(headers: Record<string, string>): string[] {
function formatHeaders(headers: Record<string, string>): string[] {
const response: string[] = [];
for (const [name, value] of Object.entries(headers)) {
response.push(`- ${name}:${value}`);
}
return response;
}

function converNetworkRequestDetailedToStringDetailed(
function convertNetworkRequestDetailedToStringDetailed(
data: NetworkRequestDetailed,
): string {
const response: string[] = [];
response.push(`## Request ${data.url}`);
response.push(`Status: ${data.status}`);
response.push(`### Request Headers`);
for (const line of formatHeadlers(data.requestHeaders)) {
for (const line of formatHeaders(data.requestHeaders)) {
response.push(line);
}

Expand All @@ -292,7 +292,7 @@ function converNetworkRequestDetailedToStringDetailed(

if (data.responseHeaders) {
response.push(`### Response Headers`);
for (const line of formatHeadlers(data.responseHeaders)) {
for (const line of formatHeaders(data.responseHeaders)) {
response.push(line);
}
}
Expand Down
Loading