-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
👍 Remove Worker
from the system (POC)
#291
Conversation
WalkthroughThe changes across various TypeScript files in the codebase reflect a significant refactoring effort. The Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (5)
- denops/@denops-private/host/base.ts (1 hunks)
- denops/@denops-private/host/nvim.ts (1 hunks)
- denops/@denops-private/host/vim.ts (1 hunks)
- denops/@denops-private/impl.ts (2 hunks)
- denops/@denops-private/service.ts (6 hunks)
Additional comments: 10
denops/@denops-private/host/base.ts (1)
- 18-23:
The return type of thebatch
method is[unknown[], string]
, which suggests it returns a single tuple. Verify if this is the intended behavior or if it should return an array of tuples, each corresponding to the result of a batch call.denops/@denops-private/host/nvim.ts (1)
- 63-67:
The changes to thebatch
method are consistent with the pull request summary and follow TypeScript best practices. The use of a rest parameter with tuple types ensures type safety and immutability of the input arguments. The method correctly maps the calls to the expected format for 'nvim_call_atomic' and handles errors appropriately.denops/@denops-private/host/vim.ts (1)
- 39-43:
The change to thebatch
method signature to use a rest parameter of type(readonly [string, ...unknown[]])[]
is consistent with the goal of enforcing immutability. Ensure that all calls to this method throughout the codebase are updated to pass immutable arrays.denops/@denops-private/impl.ts (3)
5-16:
Verify if thedispatcher
property should be public or if it was intended to be private or protected.35-44:
The changes to thebatch
method correctly handle the new tuple type arguments and maintain consistent error handling.51-68:
Thedispatch
method is correctly updated to interact with theService
instance and is appropriately marked as async.denops/@denops-private/service.ts (4)
26-30:
The_trace
parameter is not used in theregister
method. If this is intentional and reserved for future use, consider documenting its purpose to avoid confusion.45-45:
The error handling for already registered plugins is clear and informative.115-120:
The error handling in thedispatch
method is consistent with the requirements of Vim/Neovim, which do not handle JavaScript Error instances.126-128:
Thedispose
method is currently a no-op. If this method is not intended to be implemented in the future, consider removing it to reduce confusion. If it is part of theDisposable
interface or reserved for future use, document its current state and intended purpose.
const denops = new DenopsImpl(name, meta, this); | ||
// Import module with fragment so that reload works properly | ||
// https://github.com/vim-denops/denops.vim/issues/227 | ||
const suffix = `#${performance.now()}`; | ||
const scriptUrl = resolveScriptUrl(script); | ||
worker.postMessage({ scriptUrl: `${scriptUrl}${suffix}`, meta, trace }); | ||
const session = buildServiceSession( | ||
name, | ||
meta, | ||
readableStreamFromWorker(worker), | ||
writableStreamFromWorker(worker), | ||
this, | ||
trace, | ||
); | ||
import(`${scriptUrl}${suffix}`).then(async (mod) => { | ||
try { | ||
await denops.cmd( | ||
`doautocmd <nomodeline> User DenopsSystemPluginPre:${name}`, | ||
) | ||
.catch((e) => | ||
console.warn( | ||
`Failed to emit DenopsSystemPluginPre:${name}: ${e}`, | ||
) | ||
); | ||
await mod.main(denops); | ||
await denops.cmd( | ||
`doautocmd <nomodeline> User DenopsSystemPluginPost:${name}`, | ||
) | ||
.catch((e) => | ||
console.warn( | ||
`Failed to emit DenopsSystemPluginPost:${name}: ${e}`, | ||
) | ||
); | ||
} catch (e) { | ||
console.error(e); | ||
await denops.cmd( | ||
`doautocmd <nomodeline> User DenopsSystemPluginFail:${name}`, | ||
) | ||
.catch((e) => | ||
console.warn( | ||
`Failed to emit DenopsSystemPluginFail:${name}: ${e}`, | ||
) | ||
); | ||
} | ||
}); | ||
this.#plugins.set(name, { | ||
script, | ||
worker, | ||
session, | ||
client: new Client(session, { errorDeserializer }), | ||
denops, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider improving error handling within the dynamic import. Logging to the console may not be sufficient for production environments. It might be beneficial to implement a more robust error reporting mechanism or to rethrow the error after logging.
See #293 |
TBW
Summary by CodeRabbit
Refactor
batch
function across various classes for improved type handling.Service
instance, enhancing the plugin's architecture.Service
class by integratingDenopsImpl
and simplifying method calls.Chores
Session
type and associated properties to clean up the codebase.dispose
method in theService
class.