-
Notifications
You must be signed in to change notification settings - Fork 4
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
Webstreams #70
base: master
Are you sure you want to change the base?
Webstreams #70
Conversation
|
||
const reader = transformedStream.getReader(); | ||
|
||
for (;;) { |
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.
for (;;) { | |
while (true) { |
kanske en gnutta mer lättläst?
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.
Praxis verkar vara att använda for…of
loopar för att tugga igenom web streams – docs/api/webstreams.html#async-iteration. Varför gör vi inte det?
for await (const chunk of transformedStream) {
if (chunk.done) break;
body += chunk.value;
}
response.statusCode = statusCode; | ||
if (location) { | ||
response.headers = response.headers || {}; | ||
response.headers.location = location; | ||
} | ||
this.destroy(); |
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.
Hur funkar det här nu istället, chunk.done
?
if (text) { | ||
return this.evaluator.ontext(text, next); | ||
return await this.evaluator.ontext(text, controller); |
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.
behövs await
?
context.breakHit = context.breakHit || context.shouldWrite(); | ||
return context.breakHit ? next(null, { name: "esi:break" }) : next(); | ||
if (context.breakHit) controller.enqueue({ name: "esi:break" }); |
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.
Varför används controller.enqueue
istället för return
här?
Känns som att det blandas ganska friskt med att använda controller eller return… ESIEvaluator
borde väl kunna låta alla ESITag
jobba med bara returvärden / kasta fel?
lib/ListenerContext.js
Outdated
// if this is localhost and we have a computeAtEdge config when we need to map to a | ||
// backend | ||
if (host === this.options.localhost && self.options.computeAtEdge) { | ||
backend = self.options.computeAtEdge.defaultBackend; | ||
// maybe we have different backends, let's check | ||
if (self.options.computeAtEdge.pathToBackend) { | ||
// FIXME: implement | ||
} | ||
} |
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.
😵💫 Mycket options. Vet inte om jag hänger inte med… Är det typ i test: adress är http://localhost; i edge: adress är https://app-env.bn.nr ?
@@ -15,19 +15,13 @@ | |||
], | |||
"author": "Bonnier News", | |||
"license": "MIT", | |||
"peerDependencies": { | |||
"@bonniernews/atlas-html-stream": ">=2", |
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.
Varför är det här inte längre en peer dependency? Det är ju ett paket som importas i koden. Går ju inte bara att ha som dev dependency.
mock.method(global, "fetch", (url, options) => { | ||
if (!(url === "http://mystuff/" && options.method === "GET" && !options.headers["content-type"])) { |
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.
Sånt här är ju inte helt optimalt. URL-encoding, case insensitivity, timeouts etc… Finns det någon typ polyfill av fetch man kan skicka som tredje argument så nock kan fånga upp riktiga anrop?
test/localEsiTest.js
Outdated
if (!(url === "http://mystuff/" && options.method === "GET" && !options.headers["content-type"])) { | ||
return { status: 404 }; | ||
} | ||
return { body: ReadableStream.from(evalResponse), status: 200 }; |
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.
Returnvärdet ska vara en promise
test/localEsiTest.js
Outdated
if (url === "http://mystuff/case-insensitive" && options.method === "GET" && options.headers["extra-header"] === "Case insensitive") { | ||
return { body: ReadableStream.from("header name is case insensitive"), status: 200 }; | ||
} |
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.
xD testar väl inte längre case sensitivity?
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.
oops
const markup = "<esi:include src=\"/mystuff/\" dca=\"none\"/><p>efter</p>"; | ||
|
||
mock.method(global, "fetch", (url, options) => { | ||
if (!(url === "http://localhost:1234/mystuff/" && options.method === "GET" && options.backend === "origin" && options.headers.foo === "bar")) { |
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.
fetch
tar väl inte options.backend
? Eller är det en egenhet i Fastly's edge miljö?
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.
det är fastlys
@markusn, is this still relevant, or can we close it? |
based on the fastly branch