MaarrkM
Denoβ€’2y agoβ€’
3 replies
Maarrk

Error with fetch called from npm module

I am trying to use the tsdav NPM package with Deno, and have run into a problem with making an HTTP request, which seems specific to Deno.

When I try to call any request method from the library, I get an error with HttpsClientRequest somewhere deep within some compatibility layer:
error: TypeError: Cannot read properties of undefined (reading 'write')
    at HttpsClientRequest._writeRaw (ext:deno_node/_http_outgoing.ts:422:24)
    at HttpsClientRequest._send (ext:deno_node/_http_outgoing.ts:408:17)
    at HttpsClientRequest.write_ (ext:deno_node/_http_outgoing.ts:316:16)
    at HttpsClientRequest.write (ext:deno_node/_http_outgoing.ts:293:17)
    at writeToStream (file:///C:/Users/Marek/AppData/Local/deno/npm/registry.npmjs.org/node-fetch/2.7.0/lib/index.js:654:8)
    at file:///C:/Users/Marek/AppData/Local/deno/npm/registry.npmjs.org/node-fetch/2.7.0/lib/index.js:1726:3
    at new Promise (<anonymous>)
    at Function.fetch (file:///C:/Users/Marek/AppData/Local/deno/npm/registry.npmjs.org/node-fetch/2.7.0/lib/index.js:1447:9)
    at Function.fetch (file:///C:/Users/Marek/AppData/Local/deno/npm/registry.npmjs.org/cross-fetch/4.0.0/dist/node-ponyfill.js:10:20)
    at file:///C:/Users/Marek/AppData/Local/deno/npm/registry.npmjs.org/tsdav/2.0.7/dist/tsdav.cjs.js:198:42


Possibly relevant links:
- The tsdav library: https://tsdav.vercel.app/ https://www.npmjs.com/package/tsdav
- Implementation of fetch that gets called by them: https://www.npmjs.com/package/node-fetch
- The test showing this error: https://github.com/Maarrk/silverbullet-carddav/blob/ed209cb939b935cfe50169dbff7ba8ed2df7771c/online.test.ts#L27-L30

I've only used Deno for a few weeks but I really like it so far, thanks in advance for any help or pointers to relevant docs 😊

I couldn't even find the _http_outgoing.ts in my local deno folder on my own...
webdav request made easy
npm
WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser. Latest version: 2.0.7, last published: 2 months ago. Start using tsdav in your project by running npm i tsdav. There are 4 other projects in the npm registry using tsdav.
tsdav
npm
A light-weight module that brings Fetch API to node.js. Latest version: 3.3.2, last published: 7 months ago. Start using node-fetch in your project by running npm i node-fetch. There are 33917 other projects in the npm registry using node-fetch.
node-fetch
GitHub
A SilverBullet Plug to sync personal contacts with a CardDAV server - Maarrk/silverbullet-carddav
silverbullet-carddav/online.test.ts at ed209cb939b935cfe50169dbff7b...
Was this page helpful?