Skip to content

Tile requests fail depending on URL length #248

@donmccurdy

Description

@donmccurdy

Minimal reproduction:

const pad = ''.padEnd(4096, ' '); // 2048 OK, 4096 FAIL, 8192 OK

const sqlQuery = `
  SELECT *
  FROM${pad}\`carto-demo-data.demo_tables.retail_stores\`
`;

data = vectorQuerySource({
  accessToken: import.meta.env.VITE_CARTO_ACCESS_TOKEN,
  connectionName: 'carto_dw',
  sqlQuery,
  filters
});

For URLs lengths of roughly 3000–7000, the TileJSON GET request succeeds, but subsequent tile loading requests fail with error 414 URI Too Long. After the URL length exceeds 7000 characters, @carto/api-client switches to POST requests with hashed versions of the SQL query, and tile requests succeed again.

The 7000 threshold was previously chosen based on the Fastly default limit of 8192 characters, but we could reduce this value in @carto/api-client. It appears that the infrastructure serving TileJSON has a higher limit than the infrastructure serving tile requests, so one succeeds and the other does not? I'm hoping to understand the actual limits before lowing the threshold arbitrarily, but the fix is likely to be a simple adjustment in:

/**
* Fastly default limit is 8192; leave some padding.
* @privateRemarks Source: @deck.gl/carto
*/
export const DEFAULT_MAX_LENGTH_URL = 7000;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions