kimyenac opened a new pull request, #5309:
URL: https://github.com/apache/zeppelin/pull/5309
### What is this PR for?
`CompletionService`
(`zeppelin-web-angular/src/app/services/completion.service.ts`) powers Monaco
editor code completion for the New UI. In `bindMonacoCompletion()`, the
`provideCompletionItems` return path converts a one-shot completion Observable
into a Promise using `.toPromise()`, which is **deprecated in RxJS 7 and
scheduled for removal in RxJS 8**. The RxJS-recommended replacement is
`firstValueFrom`/`lastValueFrom`.
This PR:
- Replaces the trailing `.toPromise()` with `firstValueFrom(...)`, wrapping
the **unchanged** `completionItem$.pipe(filter(...), take(1), map(...))`
expression. Because the pipeline already ends with `take(1)`, it emits a single
value, so `firstValueFrom` is semantically equivalent and Monaco's
`provideCompletionItems` accepts a `Promise` return.
- Imports `firstValueFrom` from the `rxjs` root (merged into the existing
`Subject` import line; the `rxjs/operators` import is unchanged).
- Removes a leftover unconditional `console.log('on receive!', data.id)`
debug statement in `onCompletion()` that printed on every `COMPLETION_LIST`
message.
No other behavioral changes.
### What type of PR is it?
Improvement
### Todos
* [x] - Replace `.toPromise()` with `firstValueFrom` over the unchanged
filter/take(1)/map pipeline
* [x] - Import `firstValueFrom` from `rxjs`
* [x] - Remove leftover debug `console.log` in `onCompletion()`
### What is the Jira issue?
[ZEPPELIN-6472](https://issues.apache.org/jira/browse/ZEPPELIN-6472)
### How should this be tested?
This repository's frontend has no unit-test infrastructure, so verification
is via lint plus a production build:
```
cd zeppelin-web-angular
npm run lint && npm run build:angular
```
Both pass. Optionally, exercise code completion in the editor for the
configured languages (python, scala) and confirm suggestions still appear and
the `on receive!` log no longer prints to the browser console.
### Questions:
* Does the license files need to update? No
* Is there breaking changes for older versions? No. Edge case worth noting:
with no completion match, the old `.toPromise()` resolved `undefined` on
completion while `firstValueFrom` rejects with `EmptyError`. In the happy path
behavior is identical because the `Subject` is never explicitly completed; the
empty-stream difference is a theoretical edge case. A `defaultValue` could be
added if reviewers prefer.
* Does this needs documentation? No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]