Skip to content
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

fix(vscode): ts server restart on file change #1424

Merged
merged 17 commits into from
May 30, 2023
Merged

fix(vscode): ts server restart on file change #1424

merged 17 commits into from
May 30, 2023

Conversation

millsp
Copy link
Member

@millsp millsp commented May 24, 2023

This PR works with prisma/prisma#19457, we now send a simpler signal for when we need to reload types via our extension, instead of watching many possible paths.

closes prisma/prisma#13946

@millsp millsp requested review from janpio and Druue May 24, 2023 19:31
@github-actions
Copy link

github-actions bot commented May 24, 2023

🤖 Pull request artifacts

file commit
pr1424-prisma.vsix 43100f3

github-actions bot added a commit that referenced this pull request May 24, 2023
@github-actions
Copy link

@Druue

This comment was marked as outdated.

github-actions bot added a commit that referenced this pull request May 25, 2023
github-actions bot added a commit that referenced this pull request May 25, 2023
github-actions bot added a commit that referenced this pull request May 25, 2023
github-actions bot added a commit that referenced this pull request May 25, 2023
@millsp millsp added this to the 4.15.0 milestone May 25, 2023
@millsp millsp changed the title fix(vscode): ts server restart on file change fix(vsce): ts server restart on file change May 25, 2023
github-actions bot added a commit that referenced this pull request May 25, 2023
github-actions bot added a commit that referenced this pull request May 25, 2023
github-actions bot added a commit that referenced this pull request May 25, 2023
@millsp millsp requested a review from janpio May 25, 2023 22:55
github-actions bot added a commit that referenced this pull request May 25, 2023
@Druue
Copy link
Contributor

Druue commented May 26, 2023

Neat! :D
(I am still getting two debug logs per but that's also the same as what it was before)

Screen.Recording.2023-05-26.at.11.48.56.mov

github-actions bot added a commit that referenced this pull request May 26, 2023
@Druue Druue modified the milestones: 4.15.0, 5.0.0, 4.16.0 May 26, 2023
github-actions bot added a commit that referenced this pull request May 26, 2023
Comment on lines +71 to +73
// macOS watcher to be removed in future releases
const rootPath = workspace.workspaceFolders?.[0].uri.path
if (os.platform() === 'darwin' && rootPath !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know that it generally, really only works on MacOS right now? And not that us while testing just were unlucky on Linux and Windows to have it not work?

(The cost of keeping it running on Linux and Windows seems minimal, if we are not sure if for some users it still does what it should and triggers reloads for old CLI versions)

},
})
console.log(`Watching ${rootPath} for changes (old watcher).`)
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of doing either/or, instead of just both?
Even on MacOS in theory the first old variant could fail - and then the new one could catch it?

console.debug('File Watcher is disabled.')
}
} else {
console.debug('File Watcher was skipped, rootPath is falsy')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This special case is not needed any more today?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new changes, it does not matter if the rootPath is falsy, the watcher will still work.

Comment on lines +209 to +214
// when the file watcher settings change, we need to ensure they are applied
workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration('prisma.fileWatcher')) {
setGenerateWatcher(!!workspace.getConfiguration('prisma').get('fileWatcher'))
}
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why now here in context.subscriptions.push vs outside where this was handled before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's two ways of writing the same thing.

@Jolg42 Jolg42 changed the title fix(vsce): ts server restart on file change fix(vscode): ts server restart on file change May 30, 2023
Copy link
Member

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we can improve some things later probably, but it's already very valuable for many users 🙌🏼

@Jolg42 Jolg42 modified the milestones: 4.16.0, 4.15.0 May 30, 2023
@Jolg42 Jolg42 merged commit 8c1180d into main May 30, 2023
7 checks passed
@Jolg42 Jolg42 deleted the fix/file-watcher branch May 30, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module "@prisma/client" has no exported member "PrismaClient"
4 participants