@@ -178,16 +178,6 @@ export async function setupPlayground(
178178 // get a fresh client
179179 dslClient = dslWrapper ?. getLanguageClient ( ) ;
180180 if ( ! dslClient ) {
181- // TODO @montymxb (Aug. 2nd, 2023) This is a hack to deal with the wrapper crashing when the LC tries to interface with
182- // an improperly configured LS (due to a bad grammar). The result is an editor that we cannot remove via 'dispose'.
183- // This should be removed once the issue is resolved in the monaco-components repo.
184-
185- // Setup failed, attempt to teardown resources piece by piece, before throwing an error
186- dslWrapper ?. getEditor ( ) ?. dispose ( ) ;
187- dslWrapper ?. getLanguageClient ( ) ?. dispose ( ) ;
188- dslWrapper = undefined ;
189- // clean up the UI, so the old editor is visually removed (tends to linger otherwise)
190- rightEditor . innerHTML = '' ;
191181 throw new Error ( 'Failed to retrieve fresh DSL LS client' ) ;
192182 }
193183
@@ -233,10 +223,17 @@ async function getFreshDSLWrapper(
233223 monarchGrammar : generateMonarch ( Grammar , languageId )
234224 } ) , htmlElement ) . then ( ( ) => {
235225 return wrapper ;
236- } ) . catch ( ( e ) => {
226+ } ) . catch ( async ( e ) => {
237227 console . error ( 'Failed to start DSL wrapper: ' + e ) ;
238228 // don't leak the worker on failure to start
229+ // normally we wouldn't need to manually terminate, but if the LC is stuck in the 'starting' state, the following dispose will fail prematurely
230+ // and the worker will leak
239231 worker . terminate ( ) ;
232+ // try to cleanup the existing wrapper (but don't fail if we can't complete this action)
233+ // particularly due to a stuck LC, which can cause this to fail part-ways through
234+ try {
235+ await wrapper . dispose ( ) ;
236+ } catch ( e ) { }
240237 return undefined ;
241238 } ) ;
242239}
0 commit comments