Skip to content

Fix TypeError from trying to read directory #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/extension/noConfigDebugInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ export async function registerNoConfigDebug(
);

// create file system watcher for the debuggerAdapterEndpointFolder for when the communication port is written
const fileSystemWatcher = createFileSystemWatcher(new RelativePattern(tempDirPath, '**/*'));
const fileSystemWatcher = createFileSystemWatcher(new RelativePattern(tempDirPath, '**/*.txt'));
const fileCreationEvent = fileSystemWatcher.onDidCreate(async (uri) => {
sendTelemetryEvent(EventName.DEBUG_SESSION_START, undefined, {
trigger: 'noConfig' as TriggerType,
});

const filePath = uri.fsPath;
fs.readFile(filePath, (err, data) => {
const dataParse = data.toString();
if (err) {
traceError(`Error reading debuggerAdapterEndpoint.txt file: ${err}`);
return;
}
try {
// parse the client port
const dataParse = data.toString();
const jsonData = JSON.parse(dataParse);
const clientPort = jsonData.client?.port;
traceVerbose(`Parsed client port: ${clientPort}`);
Expand Down
5 changes: 4 additions & 1 deletion src/test/unittest/noConfigDebugInit.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ suite('setup for no-config debug scenario', function () {

// Assert
sinon.assert.calledOnce(createFileSystemWatcherFunct);
const expectedPattern = new RelativePattern(path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'), '**/*');
const expectedPattern = new RelativePattern(
path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'),
'**/*.txt',
);
sinon.assert.calledWith(createFileSystemWatcherFunct, expectedPattern);
});

Expand Down
Loading