Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

WIP: Modify response to add body in React Native and logging daemon requests #2874

Closed
wants to merge 23 commits into from
Closed

WIP: Modify response to add body in React Native and logging daemon requests #2874

wants to merge 23 commits into from

Conversation

pcowgill
Copy link
Contributor

@pcowgill pcowgill commented Mar 9, 2020

Closes #2847

This is still a draft. There still is an open discussion about whether this change should land in this package or upstream in React Native itself.

This PR is an updated version of ipfs-inactive/js-ipfs-http-client#1224 now that the ipfs-http-client package has become part of the js-ipfs monorepo.

Comment on lines +1 to +4
.DS_Store
.connect-deps-cache/
.connect-deps.json
prettier.config.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any objections to these changes making it into the .gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hugomrdias @achingbrain Thoughts? Thanks!

@@ -32,16 +32,18 @@ module.exports = configure(({ ky }) => {
if (options.preload != null) searchParams.set('preload', options.preload)
if (options.fileImportConcurrency != null) searchParams.set('file-import-concurrency', options.fileImportConcurrency)
if (options.blockWriteConcurrency != null) searchParams.set('block-write-concurrency', options.blockWriteConcurrency)


const formData = await toFormData(input)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hugomrdias @achingbrain Do you have any stylistic objections to building formData in a separate line like this?

packages/ipfs/package.json Outdated Show resolved Hide resolved
Comment on lines +171 to +175
// Just for logging
for await (const chunk of entry.content) {
console.log({ chunk })
}
// end of extra logging code
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't merge until we remove this

await consumeUntilAfter(stream, Buffer.from(boundary))

for await (const chunk of stream) {
console.log('multipart chunk', chunk)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied and pasted the contents of the it-multipart package into this repo so that there is a record of the log statements that were added when testing IPFS in React Native

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a linting error unless we add the deps of that package as deps for ipfs-multipart https://github.com/achingbrain/it/blob/42faa5aeb9de0e07c956d73020bd74fd08e3029d/packages/it-multipart/package.json#L17-L20

@@ -1,7 +1,7 @@
'use strict'

const Content = require('@hapi/content')
const multipart = require('it-multipart')
const multipart = require('./it-multipart')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcowgill
Copy link
Contributor Author

@hugomrdias @achingbrain I updated this PR with the upstream changes from Hugo's PR removing ky from ipfs-http-client. A TODO will be making some of the body related changes in the new react-native-community/fetch rather than here. react-native-community/fetch#3

@@ -13,7 +15,7 @@ module.exports = configure(api => {
searchParams: options
})

for await (const chunk of toIterable(res.body)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hugomrdias It's interesting that there are still some methods where this toIterable(res.body) pattern is still around.

Comment on lines +8 to 10
// TODO: Update streamToAsyncIterator with any chances in light of
// this feature branch
const { streamToAsyncIterator, ndjson } = require('../lib/core')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hugomrdias Can you give a short description of the new approach with streamToAsyncIterator compared with toIterable? Thanks!

Comment on lines +51 to 54
// Note: It's interesting that subscribe
// keeps this ndjson(tranformation(res)) pattern although
// that's now long from other IPFS methods
readMessages(ndjson(streamToAsyncIterator(res)), {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hugomrdias For parallelism, would it make sense to get rid of this ndjson(transformer(res)) pattern here too since it was removed for other IPFS methods in the ky removal PR?

@hugomrdias
Copy link
Member

Closing this in favor of #2813
Thank you.

@hugomrdias hugomrdias closed this Jun 18, 2020
@pcowgill pcowgill deleted the feature/logging-requests-and-stub-body branch June 19, 2020 19:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle case where res.body is undefined after making a request
2 participants