Skip to content

Commit

Permalink
fix: always unwrap streams
Browse files Browse the repository at this point in the history
Since awaiting a promising recursively unwraps it, returning a stream from an
async function will attempt to wait the first value of the stream, hence we
need to unpromisify when the return value of a handler is Promise<Stream>
  • Loading branch information
pemrouz committed Nov 12, 2017
1 parent 5b0f2f5 commit 5c3ecca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ const xres = async (ripple, req, res) => {
const resource = ripple.resources[req.data.name]
, { from = noop } = resource.headers

return from(req, res)
return unpromise(from(req, res))
}

const unpromise = d => (d && d.next ? d.unpromise() : d)

const subscribe = (ripple, req, res) => ripple
.on('change')
.on('start', () => {
Expand Down Expand Up @@ -78,9 +80,7 @@ const upload = async (ripple, req, res) => {
const subset = (target = '') => (source = '') => source.startsWith(target)

const by = require('utilise/by')
, is = require('utilise/is')
, key = require('utilise/key')
, noop = require('utilise/noop')
, header = require('utilise/header')
, emitterify = require('utilise/emitterify')
, nametype = (name, type) => `(${name ? name + ', ' : ''}${type ? type : ''})`

0 comments on commit 5c3ecca

Please sign in to comment.