Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grc.imagemosaics.getGranules() fails without error message #89

Open
JakobMiksch opened this issue Jul 1, 2022 · 0 comments
Open

grc.imagemosaics.getGranules() fails without error message #89

JakobMiksch opened this issue Jul 1, 2022 · 0 comments

Comments

@JakobMiksch
Copy link
Contributor

JakobMiksch commented Jul 1, 2022

const result = await grc.imagemosaics.getGranules(workspace, covStore, coverage);
  • Fails for an existing and working URL without error message
  • Credentials are set correctly.
  • Other GET requests work fine.
  • GeoServer version 2.21.0.
  • geoserver-node-client version 1.1.0

Running an minimal example shows the same problem.

import fetch from 'node-fetch';

(async () => {
   const url = 'http://localhost:8080/geoserver/rest/workspaces/klips/coveragestores/foo/coverages/jm-mosaic/index/granules.json';
   const response = await fetch(url, {
       credentials: 'include',
       method: 'GET',
       headers: {
           'Authorization': 'Basic ????'
       }
   });
   console.log('Before JSON');
   const result = await response.json();
   //                                                                     <-- THE PROGRAM STOPS HERE WITHOUT ERROR message
   console.log('After JSON');
   console.log(result);    
})();

Interestingly when node-fetch v3 is used. The program still fails but throws this error message:

file:///..../geoserver-node-client/node_modules/node-fetch/src/body.js:234
                const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, 'system', error);
                                                                         ^

FetchError: Invalid response body while trying to fetch http://localhost:8080/geoserver/rest/workspaces/klips/coveragestores/foo/coverages/jm-mosaic/index/granules.json: Premature close
    at consumeBody (file:///.../geoserver-node-client/node_modules/node-fetch/src/body.js:234:60)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Response.text (file:///.../geoserver-node-client/node_modules/node-fetch/src/body.js:158:18)
    at async Response.json (file://.../geoserver-node-client/node_modules/node-fetch/src/body.js:148:16)
    at async file:///.../geoserver-node-client/demo/demo.js:16:20 {
  type: 'system',
  errno: 'ERR_STREAM_PREMATURE_CLOSE',
  code: 'ERR_STREAM_PREMATURE_CLOSE',
  erroredSysCall: undefined

Calling the same URL with axios works fine:

import axios from 'axios';

(async () => {
   var config = {
    method: 'get',
    url: 'http://localhost:8080/geoserver/rest/workspaces/klips/coveragestores/foo/coverages/jm-mosaic/index/granules.json',
    headers: {
        'Authorization': 'Basic ????'
    }
    };

    axios(config)
    .then(function (response) {
    console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
    console.log(error);
    });
})();

Update 2022-07-05

It seems to be a problem of GeoServer 2.21.0. I tested it with GeoServer 2.20.5, there the function runs like it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant