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: playground error when returning a function declaration VSCODE-669 #925

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

nirinchev
Copy link
Contributor

Description

When the last statement in a playground is a function declaration, we would error out with a misleading error claiming the playground services crashed due to OOM. The reality was that we were trying to return a function via the language server protocol, which is not supported and was crashing the language server. This change replaces the printable when it is a function with undefined.

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
nirinchev Nikola Irinchev
@@ -17,7 +16,7 @@ interface EvaluationResult {
type: string | null;
}

const getContent = ({ type, printable }: EvaluationResult): Document => {
const getContent = ({ type, printable }: EvaluationResult): any => {
Copy link
Contributor

Choose a reason for hiding this comment

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

could unknown be better?

): 'json' | 'plaintext' => {
const content = getContent(evaluationResult);

export const getLanguage = (content: any): 'json' | 'plaintext' => {
Copy link
Contributor

Choose a reason for hiding this comment

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

could also potentially be unknown?

Copy link
Contributor

@alenakhineika alenakhineika Jan 28, 2025

Choose a reason for hiding this comment

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

It should default to plaintext if this is not a json. This defines the type of virtual document we open with a playground result.

Copy link
Contributor

Choose a reason for hiding this comment

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

was referring to any => unknown, I think we don't know much about the content then right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see! I thought you were talking about the return type.

Verified

This commit was signed with the committer’s verified signature.
nirinchev Nikola Irinchev
@nirinchev nirinchev merged commit c0617e9 into main Jan 29, 2025
9 checks passed
@nirinchev nirinchev deleted the ni/playground-function branch January 29, 2025 12:55
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.

None yet

3 participants