1
0
Fork 0

Automatically set up content_length_workaround

This commit is contained in:
Cadence Ember 2024-09-26 09:59:13 +12:00
parent 8743910c35
commit 69c93ca9d9

View file

@ -5,7 +5,7 @@ const mixin = require("@cloudrac3r/mixin-deep")
const stream = require("stream") const stream = require("stream")
const getStream = require("get-stream") const getStream = require("get-stream")
const {reg} = require("./read-registration.js") const {reg, writeRegistration} = require("./read-registration.js")
const baseUrl = `${reg.ooye.server_origin}/_matrix` const baseUrl = `${reg.ooye.server_origin}/_matrix`
@ -45,13 +45,15 @@ async function mreq(method, url, body, extra = {}) {
const root = await res.json() const root = await res.json()
if (!res.ok || root.errcode) { if (!res.ok || root.errcode) {
if (root.error?.includes("Content-Length")) { if (root.error?.includes("Content-Length") || !reg.ooye.content_length_workaround) {
console.error(`OOYE cannot stream uploads to Synapse. Please choose one of these workarounds:` reg.ooye.content_length_workaround = true
+ `\n * Run an nginx reverse proxy to Synapse, and point registration.yaml's` const root = await mreq(method, url, body, extra)
+ `\n \`server_origin\` to nginx` console.error("OOYE cannot stream uploads to Synapse. The `content_length_workaround` option"
+ `\n * Set \`content_length_workaround: true\` in registration.yaml (this will` + "\nhas been activated in registration.yaml, which works around the problem, but"
+ `\n halve the speed of bridging d->m files)`) + "\nhalves the speed of bridging d->m files. A better way to resolve this problem"
throw new Error("Synapse is not accepting stream uploads, see the message above.") + "\nis to run an nginx reverse proxy to Synapse and re-run OOYE setup.")
writeRegistration(reg)
return root
} }
delete opts.headers.Authorization delete opts.headers.Authorization
throw new MatrixServerError(root, {baseUrl, url, ...opts}) throw new MatrixServerError(root, {baseUrl, url, ...opts})