*Catch error in stream and close the stream

This commit is contained in:
Derrick Hammer 2022-09-19 16:51:02 -04:00
parent 48ef0411b3
commit d37926dd84
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 9 additions and 4 deletions

View File

@ -230,10 +230,15 @@ export default class IpfsProvider extends BaseProvider {
// @ts-ignore // @ts-ignore
fetchMethod?.(hash, urlPath, (data: Buffer) => { fetchMethod?.(hash, urlPath, (data: Buffer) => {
streamWriter.write(data); streamWriter.write(data);
}).then(() => { })
streamWriter.releaseLock(); .then(() => {
return reqStream.close(); streamWriter.releaseLock();
}); return reqStream.close();
})
.catch((e: any) => {
streamWriter.releaseLock();
reqStream.close();
});
return {}; return {};
} }