microsoft / microsoft/TypeScript-Website

Error during textUpdated

Open
#3,376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.6k
Forks
1.5k
Avg merge
2d 2h
Merged PRs (30d)
7

Description

short question before oepning a PR:

the following bug is part of the sanbox code , but not necessarily from the playground website ,im also using it in my own site
ive checked the code, and it looks similar enough so i assume it could be considered a bug
(update: ive played around a bit on the website and it seems that due to the amount of entire page reloads ur doing this is not an issue here 🤔)

Page URL: local page

Issue:
in https://github.com/microsoft/TypeScript-Website/blob/v2/packages/sandbox/src/index.ts#L227

const code = editor.getModel()!.getValue()

im getting

TypeError: can't access property "getValue", editor.getModel() is null
textUpdated index.ts:227
createTypeScriptSandbox index.ts:246

coming from the setTimeout in
https://github.com/microsoft/TypeScript-Website/blob/v2/packages/sandbox/src/index.ts#L246

i think this is mainly caused when the editor is disposed before the setTimeout finishes

my PR would just be to return the function if the model isnt there currently , this way there at least isnt an error

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/sandbox/src/index.ts at textUpdated around line 227 and the setTimeout in createTypeScriptSandbox around line 246. Reproduce disposal before the timeout completes, then verify the sandbox no longer throws when editor.getModel() is null.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.