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

Disables the byte-range for /documents/pdf_content #29

Conversation

santostelmo
Copy link
Member

We get the following traceback when trying to access documents on futurplus 16.0:

image

The concerned endpoint is /documents/pdf_content where the library pdfjs is used.

We have seen that byte-range [begin,end] is not properly calculated in pdfjs:
futurplus_odoo_v16/odoo/src/addons/web/static/lib/pdfjs/build/pdf.js

var PDFFetchStreamRangeReader =
/*#__PURE__*/
function () {
  function PDFFetchStreamRangeReader(stream, begin, end) {
    var _this2 = this;

    _classCallCheck(this, PDFFetchStreamRangeReader);

    this._stream = stream;
    this._reader = null;
    this._loaded = 0;
    var source = stream.source;
    this._withCredentials = source.withCredentials || false;
    this._readCapability = (0, _util.createPromiseCapability)();
    this._isStreamingSupported = !source.disableStream;

    if (typeof AbortController !== 'undefined') {
      this._abortController = new AbortController();
    }

    this._headers = new Headers();

    for (var property in this._stream.httpHeaders) {
      var value = this._stream.httpHeaders[property];

      if (typeof value === 'undefined') {
        continue;
      }

      this._headers.append(property, value);
    }
   
    /* BYTE-RANGE NOT PROPERLY CALCULATED */
    this._headers.append('Range', "bytes=".concat(begin, "-").concat(end - 1));

    var url = source.url;
    fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
      if (!(0, _network_utils.validateResponseStatus)(response.status)) {
        throw (0, _network_utils.createResponseStatusError)(response.status, url);
      }

      _this2._readCapability.resolve();

      _this2._reader = response.body.getReader();
    });
    this.onProgress = null;
  }

Desactivate byte-range on the endpoint /documents/pdf_content prevents the error.
max_ranges 0;

Copy link
Member

@p-tombez p-tombez left a comment

Choose a reason for hiding this comment

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

Since the library version used is more than 4 years old, shouldn't it be better to check if the error was fixed and update the lib instead of disabling a feature in Nginx ?

@santostelmo
Copy link
Member Author

Since the library version used is more than 4 years old, shouldn't it be better to check if the error was fixed and update the lib instead of disabling a feature in Nginx ?

What is the version installed ?

@p-tombez
Copy link
Member

Since the library version used is more than 4 years old, shouldn't it be better to check if the error was fixed and update the lib instead of disabling a feature in Nginx ?

What is the version installed ?

2.2.228

@santostelmo
Copy link
Member Author

Since the library version used is more than 4 years old, shouldn't it be better to check if the error was fixed and update the lib instead of disabling a feature in Nginx ?

What is the version installed ?

2.2.228

I'll patch src code with the most recent version https://www.npmjs.com/package/pdfjs-dist/v/3.10.111 to see if it works

@santostelmo
Copy link
Member Author

Since the library version used is more than 4 years old, shouldn't it be better to check if the error was fixed and update the lib instead of disabling a feature in Nginx ?

What is the version installed ?

2.2.228

I'll patch src code with the most recent version https://www.npmjs.com/package/pdfjs-dist/v/3.10.111 to see if it works

Actually that library has a lot of dependencies, so I would have to check compatibility which can take a lot of time.
Is possible to apply a specific nginx configuration for futurplus ?

@vrenaville
Copy link
Member

I close it in favor of : #28

@vrenaville vrenaville closed this Sep 11, 2023
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

Successfully merging this pull request may close these issues.

4 participants