Skip to content

Commit 4ae1de8

Browse files
committed
Merge remote-tracking branch 'origin/master' into chat-threads-smaller
2 parents c24dade + 517f3ae commit 4ae1de8

File tree

16 files changed

+100
-33
lines changed

16 files changed

+100
-33
lines changed

src/packages/database/settings/auth-sso-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export type PassportLoginInfo = { [key in LoginInfoKeys]?: string };
8080
* The remaining fields, except for type, clientID, clientSecret, and callbackURL, userinfoURL, login_info are passed to that constructor.
8181
* Additionally, there are default values for some of the fields, e.g. for the SAML2.0 strategy.
8282
* Please check the hub/auth.ts file for more details.
83+
*
8384
* Regarding the userinfoURL, this is used by OAuth2 to get the profile.
85+
*
8486
* The "login_info" field is a mapping from "cocalc" profile fields, that end up in the DB,
8587
* to the entries in the generated profile object. The DB entry can only be a string and
8688
* processing is done by using the "dot-object" npm library.
@@ -91,6 +93,7 @@ export type PassportLoginInfo = { [key in LoginInfoKeys]?: string };
9193
* last_name: "name.familyName",
9294
* emails: "emails[0].value",
9395
* }
96+
* You can to customize the separator of dot-object, e.g. to process keys with dots, add a "_sep: string" entry.
9497
*/
9598
export interface PassportStrategyDBConfig {
9699
type: PassportTypes;

src/packages/frontend/jupyter/cell-input.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ export const CellInput: React.FC<CellInputProps> = React.memo(
153153
return (
154154
<CodeMirror
155155
actions={
156-
props.input_is_readonly ? undefined : props.actions
156+
props.is_readonly || props.input_is_readonly
157+
? undefined
158+
: props.actions
157159
/* Do NOT pass in actions when read only, since having any actions *defines*
158160
not read only for the codemirror editor; also, it will get created with
159161
potentially the same id as a normal cell, hence get linked to it, and

src/packages/frontend/project_actions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3581,7 +3581,10 @@ export class ProjectActions extends Actions<ProjectStoreState> {
35813581
return this.computeServerManager?.get(canonicalPath(path));
35823582
};
35833583

3584-
// in case of confirmation, returns true on success or false if user says "no"
3584+
// In case of confirmation, returns true on success or false if user says "no"
3585+
// Also, no matter what, we NEVER explicitly request confirmation if the
3586+
// file doesn't involve backend state that could be reset, e.g., we basically
3587+
// only confirm for terminals and jupyter notebooks.
35853588
setComputeServerIdForFile = async ({
35863589
path,
35873590
compute_server_id,
@@ -3591,6 +3594,13 @@ export class ProjectActions extends Actions<ProjectStoreState> {
35913594
compute_server_id?: number;
35923595
confirm?: boolean;
35933596
}): Promise<boolean> => {
3597+
if (confirm) {
3598+
if (!path.endsWith(".term") && !path.endsWith(".ipynb")) {
3599+
// ONLY confirm when there is some danger is loss of state. Otherwise,
3600+
// this is very annoying.
3601+
confirm = false;
3602+
}
3603+
}
35943604
const selectedComputeServerId = this.getComputeServerId(compute_server_id);
35953605
const computeServerAssociations =
35963606
webapp_client.project_client.computeServers(this.project_id);

src/packages/hub/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"express": "^4.21.2",
4141
"formidable": "^3.5.4",
4242
"http-proxy": "^1.18.1",
43+
"http-proxy-3": "^1.19.3",
4344
"immutable": "^4.3.0",
4445
"jquery": "^3.6.0",
4546
"json-stable-stringify": "^1.0.1",

src/packages/hub/proxy/handle-upgrade.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export default function init(
109109
proxy.on("error", (err) => {
110110
logger.debug(`websocket proxy error, so clearing cache -- ${err}`);
111111
cache.delete(target);
112+
proxy.close();
112113
});
113114
proxy.on("close", () => {
114115
dbg("websocket proxy closed, so removing from cache");

src/packages/hub/proxy/target.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ const logger = getLogger("proxy:target");
2828
// Also, if the project stops and starts, the host=ip address could
2929
// change, so we need to timeout so we see that thange.
3030

31-
const cache = new LRU({ max: 20000, ttl: 1000 * 30 });
31+
const cache = new LRU<
32+
string,
33+
{
34+
host: string;
35+
port: number;
36+
internal_url: string | undefined;
37+
}
38+
>({ max: 20000, ttl: 1000 * 30 });
3239

3340
// This gets explicitly called from outside when certain errors occur.
3441
export function invalidateTargetCache(remember_me: string, url: string): void {

src/packages/hub/servers/nats.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export async function proxyNatsWebsocket(req, socket, head) {
3838
timeout: 5000,
3939
});
4040
proxy.ws(req, socket, head);
41+
proxy.on("error", (err) => {
42+
logger.debug(`nats websocket proxy error, so closing -- ${err}`);
43+
proxy.close();
44+
});
4145

4246
while (socket.readyState !== socket.CLOSED) {
4347
if (versionCheckFails(req)) {

src/packages/jupyter/kernel/kernel.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,6 @@ nodeCleanup(() => {
218218
}
219219
});
220220

221-
// TODO: are these the only base64 encoded types that jupyter kernels return?
222-
export const BASE64_TYPES = [
223-
"image/png",
224-
"image/jpeg",
225-
"application/pdf",
226-
"base64",
227-
] as const;
228-
229221
// NOTE: keep JupyterKernel implementation private -- use the kernel function
230222
// above, and the interface defined in types.
231223
class JupyterKernel extends EventEmitter implements JupyterKernelInterface {
@@ -760,15 +752,14 @@ class JupyterKernel extends EventEmitter implements JupyterKernelInterface {
760752
return await new CodeExecutionEmitter(this, opts).go();
761753
};
762754

763-
private saveBlob = (data: string, type?: string) => {
755+
private saveBlob = (data: string, type: string) => {
764756
const blobs = this._actions?.blobs;
765757
if (blobs == null) {
766758
throw Error("blob store not available");
767759
}
768-
const buf: Buffer =
769-
type && BASE64_TYPES.includes(type as any)
770-
? Buffer.from(data, "base64")
771-
: Buffer.from(data);
760+
const buf: Buffer = !type.startsWith("text/")
761+
? Buffer.from(data, "base64")
762+
: Buffer.from(data);
772763

773764
const sha1: string = misc_node_sha1(buf);
774765
blobs.set(sha1, buf);

src/packages/nats/time.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const INTERVAL_BAD = 5 * 1000;
6161
// If clock fails to sync this many times in a row, we reconnect to nats.
6262
const MAX_FAILS = 3;
6363

64-
const RECONNECT_LOGIC = true;
64+
const RECONNECT_LOGIC = false;
6565

6666
export function init() {
6767
syncLoop();

src/packages/pnpm-lock.yaml

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)