Skip to content

Commit 0513584

Browse files
authored
Merge pull request #25 from dynamic-calm/fix-typos
chore: fix typos
2 parents e145927 + 01c6062 commit 0513584

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ Unfortunately, garbage collection does not work well when remote resources are i
328328

329329
1. Many JavaScript runtimes only run the garbage collector when they sense "memory pressure" -- if memory is not running low, then they figure there's no need to try to reclaim any. However, the runtime has no way to know if the other side of an RPC connection is suffering memory pressure.
330330

331-
2. Garbage collectors need to trace the full object graph in order to detect which objects are unreachable, especially when those objects contain cyclic refereces. However, the garbage collector can only see local objects; it has no ability to trace through the remote graph to discover cycles that may cross RPC connections.
331+
2. Garbage collectors need to trace the full object graph in order to detect which objects are unreachable, especially when those objects contain cyclic references. However, the garbage collector can only see local objects; it has no ability to trace through the remote graph to discover cycles that may cross RPC connections.
332332

333333
Both of these problems might be solvable with sufficient work, but the problem seems exceedingly difficult. We make no attempt to solve it in this library.
334334

__tests__/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ describe("basic rpc", () => {
571571
// object's version of that property. We really want to generate messages sent to the other
572572
// end to access the remote version, but there's no legitimate way to do this via the JS-level
573573
// API. Fortunately, our transport implements a hack: the string "$remove$" will be excised
574-
// from any message. So, we can use this as a prefix on property names to create a prpoperty
574+
// from any message. So, we can use this as a prefix on property names to create a property
575575
// that does not match anything locally, but by the time it reaches the remote end, will name
576576
// a common object property.
577577

@@ -1073,7 +1073,7 @@ describe("stub disposal over RPC", () => {
10731073
[Symbol.dispose]() { targetDisposed = true; }
10741074
}
10751075

1076-
// Intentionally dont use `using` here because we expect the stats to be wrong after a
1076+
// Intentionally don't use `using` here because we expect the stats to be wrong after a
10771077
// disconnect.
10781078
let harness = new TestHarness(new DisposableTarget());
10791079
let stub = harness.stub;
@@ -1096,7 +1096,7 @@ describe("stub disposal over RPC", () => {
10961096
});
10971097

10981098
it("shuts down the connection if the main capability is disposed", async () => {
1099-
// Intentionally dont use `using` here because we expect the stats to be wrong after a
1099+
// Intentionally don't use `using` here because we expect the stats to be wrong after a
11001100
// disconnect.
11011101
let harness = new TestHarness(new TestTarget());
11021102
let stub = harness.stub;
@@ -1250,7 +1250,7 @@ describe("onRpcBroken", () => {
12501250
throwError(): Promise<Counter> { throw new Error("test error"); }
12511251
}
12521252

1253-
// Intentionally dont use `using` here because we expect the stats to be wrong after a
1253+
// Intentionally don't use `using` here because we expect the stats to be wrong after a
12541254
// disconnect.
12551255
let harness = new TestHarness(new TestBroken());
12561256
let stub = harness.stub;

__tests__/test-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function setup(project: TestProject) {
5656

5757
// Provide the server address to tests.
5858
//
59-
// We use the Node-specific `url.format` here becaues it automatically handles adding brackets to
59+
// We use the Node-specific `url.format` here because it automatically handles adding brackets to
6060
// IPv6 addresses. Unfortunately, the standard `URL` class doesn't seem to provide this.
6161
project.provide("testServerHost", url.format({hostname: addr.address, port: addr.port}));
6262
}

src/batch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class BatchClientTransport implements RpcTransport {
5050
async #scheduleBatch(sendBatch: SendBatchFunc) {
5151
// Wait for microtask queue to clear before sending a batch.
5252
//
53-
// Note that simply waiting for one turn of the microtask qeueue (await Promise.resolve()) is
53+
// Note that simply waiting for one turn of the microtask queue (await Promise.resolve()) is
5454
// not good enough here as the application needs a chance to call `.then()` on every RPC
55-
// promise in order to explicitly indicate they want the results. Unfortuntaely, `await`ing
55+
// promise in order to explicitly indicate they want the results. Unfortunately, `await`ing
5656
// a thenable does not call `.then()` immediately -- for some reason it waits for a turn of
5757
// the microtask queue first, *then* calls `.then()`.
5858
await new Promise(resolve => setTimeout(resolve, 0));
@@ -132,7 +132,7 @@ class BatchServerTransport implements RpcTransport {
132132
*
133133
* @param request The request received from the client initiating the session.
134134
* @param localMain The main stub or RpcTarget which the server wishes to expose to the client.
135-
* @param options Optional RPC sesison options.
135+
* @param options Optional RPC session options.
136136
* @returns The HTTP response to return to the client. Note that the returned object has mutable
137137
* headers, so you can modify them using e.g. `response.headers.set("Foo", "bar")`.
138138
*/
@@ -169,7 +169,7 @@ export async function newHttpBatchRpcResponse(
169169
* @param request The request received from the client initiating the session.
170170
* @param response The response object, to which the response should be written.
171171
* @param localMain The main stub or RpcTarget which the server wishes to expose to the client.
172-
* @param options Optional RPC sesison options. You can also pass headers to set on the response.
172+
* @param options Optional RPC session options. You can also pass headers to set on the response.
173173
*/
174174
export async function nodeHttpBatchRpcResponse(
175175
request: IncomingMessage, response: ServerResponse,

src/core.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export abstract class StubHook {
204204
// Called to prevent this stub from generating unhandled rejection events if it throws without
205205
// having been pulled. Without this, if a client "push"es a call that immediately throws before
206206
// the client manages to "pull" it or use it in a pipeline, this may be treated by the system as
207-
// an unhandled rejection. Unfortuntaely, this unhandled rejection would be reported in the
207+
// an unhandled rejection. Unfortunately, this unhandled rejection would be reported in the
208208
// callee rather than the caller, possibly causing the callee to crash or log spurious errors,
209209
// even though it's really up to the caller to deal with the exception!
210210
abstract ignoreUnhandledRejections(): void;
@@ -472,11 +472,11 @@ export function unwrapStubTakingOwnership(stub: RpcStub): StubHook {
472472
}
473473
}
474474

475-
// Given a stub (still wrapped in a Proxy), extract the underlying `StubHook`, and dulpicate it,
475+
// Given a stub (still wrapped in a Proxy), extract the underlying `StubHook`, and duplicate it,
476476
// returning the duplicate.
477477
//
478478
// The caller is responsible for disposing the returned hook, but the original stub also still
479-
// needs to be disposed by its owner (unless it is a proprety, which never needs disposal).
479+
// needs to be disposed by its owner (unless it is a property, which never needs disposal).
480480
//
481481
// The result is a promise (i.e. can be pull()ed) if and only if the input is a promise. Note that
482482
// this differs from the semantics of the actual `dup()` method.
@@ -493,7 +493,7 @@ export function unwrapStubAndDup(stub: RpcStub): StubHook {
493493
// Unwrap a stub returning the underlying `StubHook`, returning `undefined` if it is a property
494494
// stub.
495495
//
496-
// This function is agnostic to ownership transfer. Excatly one of `stub` or the return `hook` must
496+
// This function is agnostic to ownership transfer. Exactly one of `stub` or the return `hook` must
497497
// eventually be disposed (unless `undefined` is returned, in which case neither need to be
498498
// disposed, as properties are not normally disposable).
499499
export function unwrapStubNoProperties(stub: RpcStub): StubHook | undefined {
@@ -507,17 +507,17 @@ export function unwrapStubNoProperties(stub: RpcStub): StubHook | undefined {
507507
}
508508

509509
// Unwrap a stub returning the underlying `StubHook`. If it's a property, return the `StubHook`
510-
// representing the stub or promise of which is is a proprety.
510+
// representing the stub or promise of which is is a property.
511511
//
512-
// This function is agnostic to ownership transfer. Excatly one of `stub` or the return `hook` must
512+
// This function is agnostic to ownership transfer. Exactly one of `stub` or the return `hook` must
513513
// eventually be disposed.
514514
export function unwrapStubOrParent(stub: RpcStub): StubHook {
515515
return stub[RAW_STUB].hook;
516516
}
517517

518518
// Given a stub (still wrapped in a Proxy), extract the `hook` and `pathIfPromise` properties.
519519
//
520-
// This function is agnostic to ownership transfer. Excatly one of `stub` or the return `hook` must
520+
// This function is agnostic to ownership transfer. Exactly one of `stub` or the return `hook` must
521521
// eventually be disposed.
522522
export function unwrapStubAndPath(stub: RpcStub): {hook: StubHook, pathIfPromise?: PropertyPath} {
523523
return stub[RAW_STUB];
@@ -530,7 +530,7 @@ async function pullPromise(promise: RpcPromise): Promise<unknown> {
530530
if (pathIfPromise!.length > 0) {
531531
// If this isn't the root promise, we have to clone it and pull the clone. This is a little
532532
// weird in terms of disposal: There's no way for the app to dispose/cancel the promise while
533-
// waiting becaues it never actually got a direct disposable reference. It has to dispose
533+
// waiting because it never actually got a direct disposable reference. It has to dispose
534534
// the result.
535535
hook = hook.get(pathIfPromise!);
536536
}
@@ -616,7 +616,7 @@ export class RpcPayload {
616616
// Create a payload from a value return from an RPC implementation by the app.
617617
//
618618
// Unlike fromAppParams(), in this case the payload takes ownership of all stubs in `value`, and
619-
// may hold onto `value` for an arbitarily long time (e.g. to serve pipelined requests). It
619+
// may hold onto `value` for an arbitrarily long time (e.g. to serve pipelined requests). It
620620
// will still avoid modifying `value` and will make a deep copy if it is delivered locally.
621621
public static fromAppReturn(value: unknown): RpcPayload {
622622
return new RpcPayload(value, "return");
@@ -687,15 +687,15 @@ export class RpcPayload {
687687
// The payload value.
688688
public value: unknown,
689689

690-
// What is the provinance of `value`?
690+
// What is the provenance of `value`?
691691
// "params": It came from the app, in params to a call. We must dupe any stubs within.
692692
// "return": It came from the app, returned from a call. We take ownership of all stubs within.
693693
// "owned": This value belongs fully to us, either because it was deserialized from the wire
694694
// or because we deep-copied a value from the app.
695695
private source: "params" | "return" | "owned",
696696

697697
// `stubs` and `promises` are filled in only if `value` belongs to us (`source` is "owned") and
698-
// so can safely be delivered to the app. If `value` came from thne app in the first place,
698+
// so can safely be delivered to the app. If `value` came from then app in the first place,
699699
// then it cannot be delivered back to the app nor modified by us without first deep-copying
700700
// it. `stubs` and `promises` will be computed as part of the deep-copy.
701701

@@ -707,7 +707,7 @@ export class RpcPayload {
707707
private promises?: LocatedPromise[]
708708
) {}
709709

710-
// For `soruce === "return"` payloads only, this tracks any StubHooks created around RpcTargets
710+
// For `source === "return"` payloads only, this tracks any StubHooks created around RpcTargets
711711
// found in the payload at the time that it is serialized (or deep-copied) for return, so that we
712712
// can make sure they are not disposed before the pipeline ends.
713713
//
@@ -1214,7 +1214,7 @@ function followPath(value: unknown, parent: object | undefined,
12141214
break;
12151215

12161216
case "array":
1217-
// For arrays, restricrt specifically to numeric indexes, to be consistent with
1217+
// For arrays, restrict specifically to numeric indexes, to be consistent with
12181218
// serialization, which only sends a flat list.
12191219
if (Number.isInteger(part) && <number>part >= 0) {
12201220
value = (<any>value)[part];

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const RpcStub: {
3939
/**
4040
* Represents the result of an RPC call.
4141
*
42-
* Also used to represent propreties. That is, `stub.foo` evaluates to an `RpcPromise` for the
42+
* Also used to represent properties. That is, `stub.foo` evaluates to an `RpcPromise` for the
4343
* value of `foo`.
4444
*
4545
* This isn't actually a JavaScript `Promise`. It does, however, have `then()`, `catch()`, and
@@ -81,7 +81,7 @@ export const RpcSession: {
8181
// conditionally being imported from "cloudflare:workers".
8282
/**
8383
* Classes which are intended to be passed by reference and called over RPC must extend
84-
* `RpcTarget`. A class which does not extend `RpcTarget` (and which dosen't have built-in support
84+
* `RpcTarget`. A class which does not extend `RpcTarget` (and which doesn't have built-in support
8585
* from the RPC system) cannot be passed in an RPC message at all; an exception will be thrown.
8686
*
8787
* Note that on Cloudflare Workers, this `RpcTarget` is an alias for the one exported from the
@@ -144,7 +144,7 @@ export let newMessagePortRpcSession:<T extends Serializable<T> = Empty>
144144
export async function newWorkersRpcResponse(request: Request, localMain: any) {
145145
if (request.method === "POST") {
146146
let response = await newHttpBatchRpcResponse(request, localMain);
147-
// Since we're exposing the same API over WebSocket, too, and WebScoket always allows
147+
// Since we're exposing the same API over WebSocket, too, and WebSocket always allows
148148
// cross-origin requests, the API necessarily must be safe for cross-origin use (e.g. because
149149
// it uses in-band authorization, as recommended in the readme). So, we might as well allow
150150
// batch requests to be made cross-origin as well.

src/map.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ mapImpl.sendMap = (hook: StubHook, path: PropertyPath, func: (promise: RpcPromis
163163

164164
// Detect misuse: Map callbacks cannot be async.
165165
if (result instanceof Promise) {
166-
// Squelch unhanlded rejections from the map function itself -- it'll probably just throw
166+
// Squelch unhandled rejections from the map function itself -- it'll probably just throw
167167
// something about pulling a MapVariableHook.
168168
result.catch(err => {});
169169

@@ -205,12 +205,12 @@ class MapVariableHook extends StubHook {
205205

206206
// Other methods should never be called.
207207
call(path: PropertyPath, args: RpcPayload): StubHook {
208-
// Can't be called; all calls are incercepted.
208+
// Can't be called; all calls are intercepted.
209209
throwMapperBuilderUseError();
210210
}
211211

212212
map(path: PropertyPath, captures: StubHook[], instructions: unknown[]): StubHook {
213-
// Can't be called; all map()s are incercepted.
213+
// Can't be called; all map()s are intercepted.
214214
throwMapperBuilderUseError();
215215
}
216216

src/rpc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class RpcMainHook extends RpcImportHook {
288288
export type RpcSessionOptions = {
289289
/**
290290
* If provided, this function will be called whenever an `Error` object is serialized (for any
291-
* resaon, not just because it was thrown). This can be used to log errors, and also to redact
291+
* reason, not just because it was thrown). This can be used to log errors, and also to redact
292292
* them.
293293
*
294294
* If `onSendError` returns an Error object, than object will be substituted in place of the

src/serialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class Devaluator {
158158

159159
// TODO:
160160
// - Determine type by checking prototype rather than `name`, which can be overridden?
161-
// - Serialize cause / supressed error / etc.
161+
// - Serialize cause / suppressed error / etc.
162162
// - Serialize added properties.
163163

164164
let rewritten = this.exporter.onSendError(e);

src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ type BaseType =
8484
| Request
8585
| Response
8686
| Headers;
87-
// Recursively rewrite all `Stubable` types with `Stub`s, and resolve promsies.
87+
// Recursively rewrite all `Stubable` types with `Stub`s, and resolve promises.
8888
// prettier-ignore
8989
export type Stubify<T> =
9090
T extends Stubable ? Stub<T>

0 commit comments

Comments
 (0)