chore(chalice): enhanced sourcemaps to handle incorrect frames

This commit is contained in:
Taha Yassine Kraiem 2022-11-15 15:23:32 +01:00
parent d89ced3579
commit e6b8835728

View file

@ -54,7 +54,8 @@ def __frame_is_valid(f):
def __format_frame(f):
f["context"] = [] # no context by default
if "source" in f: f.pop("source")
if "source" in f:
f.pop("source")
url = f.pop("fileName")
f["absPath"] = url
f["filename"] = urlparse(url).path
@ -74,8 +75,13 @@ def format_payload(p, truncate_to_first=False):
def url_exists(url):
r = requests.head(url, allow_redirects=False)
return r.status_code == 200 and r.headers.get("Content-Type") != "text/html"
try:
r = requests.head(url, allow_redirects=False)
return r.status_code == 200 and r.headers.get("Content-Type") != "text/html"
except Exception as e:
print(f"!! Issue checking if URL exists: {url}")
print(e)
return False
def get_traces_group(project_id, payload):
@ -97,8 +103,8 @@ def get_traces_group(project_id, payload):
continue
if key not in payloads:
file_exists_in_bucket = s3.exists(config('sourcemaps_bucket'), key)
if not file_exists_in_bucket:
file_exists_in_bucket = len(file_url) > 0 and s3.exists(config('sourcemaps_bucket'), key)
if len(file_url) > 0 and not file_exists_in_bucket:
print(f"{u['absPath']} sourcemap (key '{key}') doesn't exist in S3 looking in server")
if not file_url.endswith(".map"):
file_url += '.map'