tentwentyfour / nextcloud-link

Javascript/Typescript client that communicates with Nextcloud's WebDAV and OCS APIs
MIT License
56 stars 7 forks source link

Uncaught exception while creating folder hierarchy #21

Open ntma opened 4 years ago

ntma commented 4 years ago

Hi tentwentyfour team,

I am developing a server which needs to create a folder hierarchy in nextcloud on user demand.

I stumbled into the case where losing the connection to the nextcloud server while executing createFolderHierarchy results in the following uncaught exception:

TypeError: Cannot read property 'statusCode' of null

Since this function does not throw any exception, I end up with my server being killed.

Is there a workaround for this?

floriansimon1 commented 4 years ago

There is no workaround AFAIK. Can you submit a PR to add an exception handler? If not, do you have a consistent reproduction protocol?

ntma commented 4 years ago

I started diving into the code of this library and found out that the issue comes from the webdav-client library.

It is missing a simple sanity test within the exists(path) (check if a path exists) method as I reported in their repository. Since the exception occurs within a callback, promisify isn't able to catch/throw that exception.. at least AFAIK.

In my opinion, this can only be solved in their side.

floriansimon1 commented 4 years ago

I think the library is unmaintained. Every time this happened to me, I submitted pull requests, and the author was kind enough to get my PRs merged.

kwisatz commented 4 years ago

There's another reason for us to either fork or ditch and replace WebDAV-Client: it still uses request which has been deprecated a while ago and isn't maintained anymore.

floriansimon1 commented 4 years ago

Not sure about how the landscape has changed, but back when I started to write that library, there was no working alternative to Webdav-client and I didn't feel like rewriting one.

That said, a move might be a good way of finally getting rid of the speed problems we currently face.

kwisatz commented 4 years ago

@floriansimon1 We've been evaluating alternative libraries or simply rewriting the necessary HTTP/WebDAV requests ourselves as we became aware of the deprecation of request.

This is slightly off-topic though, so I don't want to go into too much detail, but yeah, submitting a PR to WebDAV-Client would probably be the quickest way to solve this issue.