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

TerminalShellExecution#createDataStream #208640

Closed
jrieken opened this issue Mar 25, 2024 · 5 comments · Fixed by #209037
Closed

TerminalShellExecution#createDataStream #208640

jrieken opened this issue Mar 25, 2024 · 5 comments · Fixed by #209037
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration infrastructure, command decorations, etc. verified Verification succeeded
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Mar 25, 2024

Testing #208462

The TerminalShellExecution#createDataStream should be a plain property and not a method

@Tyriar
Copy link
Member

Tyriar commented Mar 25, 2024

I was thinking about this guideline when I switched it to a method as it's creating a new object every call:

Note: Providing synchronous data comes with some additional engineering cost and will consume extra memory. However, it guarantees fast (zero-cost) data reading.

Can switch it back, is it worth a discussion in the API sync?

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Mar 25, 2024
@Tyriar Tyriar added this to the April 2024 milestone Mar 25, 2024
@jrieken
Copy link
Member Author

jrieken commented Mar 25, 2024

createDataStream(): AsyncIterable<string> {
return that._createDataStream();
}
};
}
private _createDataStream(): AsyncIterable<string> {
if (!this._dataStream) {
if (this._exitCodeResolve === undefined) {
return AsyncIterableObject.EMPTY;
}
this._dataStream = new ShellExecutionDataStream();
}
return this._dataStream.createIterable();
}

I don't think it does create a new object but that's also not the point here. Your data is never sync with an async iterable but the point is the consumer should just have TerminalShellExecution#stream which is still an async iterable (and likely implemented as lazy getter)

@Tyriar
Copy link
Member

Tyriar commented Mar 25, 2024

@jrieken I might be doing something wrong as I don't think I've used an async iterable before, but doesn't this need to return a separate iterable per call in order to support multiple extensions? Currently the ShellExecutionDataStream is a multiplexer for multiple iterators:

return this._dataStream.createIterable();

createIterable(): AsyncIterable<string> {
const barrier = this._barrier = new Barrier();
const iterable = new AsyncIterableObject<string>(async emitter => {
this._emitters.push(emitter);
await barrier.wait();
});
return iterable;
}

@jrieken
Copy link
Member Author

jrieken commented Mar 25, 2024

Oh, I missed the createIterable invocation inside createDataStream.

@jrieken
Copy link
Member Author

jrieken commented Mar 25, 2024

Maybe a better name for a method would be read or readData.

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug api terminal-shell-integration Shell integration infrastructure, command decorations, etc. and removed info-needed Issue requires more information from poster labels Mar 25, 2024
Tyriar added a commit that referenced this issue Mar 28, 2024
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Mar 29, 2024
@jrieken jrieken added the verified Verification succeeded label Apr 24, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration infrastructure, command decorations, etc. verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants