@vercel/python 4.6.0 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1805,9 +1805,9 @@ var require_once = __commonJS({
1805
1805
  }
1806
1806
  });
1807
1807
 
1808
- // ../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js
1808
+ // ../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js
1809
1809
  var require_end_of_stream = __commonJS({
1810
- "../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js"(exports, module2) {
1810
+ "../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js"(exports, module2) {
1811
1811
  var once = require_once();
1812
1812
  var noop = function() {
1813
1813
  };
@@ -1827,6 +1827,7 @@ var require_end_of_stream = __commonJS({
1827
1827
  var rs = stream._readableState;
1828
1828
  var readable = opts.readable || opts.readable !== false && stream.readable;
1829
1829
  var writable = opts.writable || opts.writable !== false && stream.writable;
1830
+ var cancelled = false;
1830
1831
  var onlegacyfinish = function() {
1831
1832
  if (!stream.writable)
1832
1833
  onfinish();
@@ -1848,9 +1849,14 @@ var require_end_of_stream = __commonJS({
1848
1849
  callback.call(stream, err);
1849
1850
  };
1850
1851
  var onclose = function() {
1851
- if (readable && !(rs && rs.ended))
1852
+ process.nextTick(onclosenexttick);
1853
+ };
1854
+ var onclosenexttick = function() {
1855
+ if (cancelled)
1856
+ return;
1857
+ if (readable && !(rs && (rs.ended && !rs.destroyed)))
1852
1858
  return callback.call(stream, new Error("premature close"));
1853
- if (writable && !(ws && ws.ended))
1859
+ if (writable && !(ws && (ws.ended && !ws.destroyed)))
1854
1860
  return callback.call(stream, new Error("premature close"));
1855
1861
  };
1856
1862
  var onrequest = function() {
@@ -1875,6 +1881,7 @@ var require_end_of_stream = __commonJS({
1875
1881
  stream.on("error", onerror);
1876
1882
  stream.on("close", onclose);
1877
1883
  return function() {
1884
+ cancelled = true;
1878
1885
  stream.removeListener("complete", onfinish);
1879
1886
  stream.removeListener("abort", onclose);
1880
1887
  stream.removeListener("request", onrequest);
@@ -3109,7 +3116,8 @@ var build = async ({
3109
3116
  files,
3110
3117
  handler: `${handlerPyFilename}.vc_handler`,
3111
3118
  runtime: pythonVersion.runtime,
3112
- environment: {}
3119
+ environment: {},
3120
+ supportsResponseStreaming: true
3113
3121
  });
3114
3122
  return { output };
3115
3123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "4.6.0",
3
+ "version": "4.7.1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -19,7 +19,7 @@
19
19
  "@types/jest": "27.4.1",
20
20
  "@types/node": "14.18.33",
21
21
  "@types/which": "3.0.0",
22
- "@vercel/build-utils": "9.0.0",
22
+ "@vercel/build-utils": "9.1.0",
23
23
  "cross-env": "7.0.3",
24
24
  "execa": "^1.0.0",
25
25
  "fs-extra": "11.1.1",
package/vc_init.py CHANGED
@@ -27,7 +27,7 @@ def format_headers(headers, decode=False):
27
27
  keyToList[key].append(value)
28
28
  return keyToList
29
29
 
30
- if 'VERCEL_IPC_FD' in os.environ or 'VERCEL_IPC_PATH' in os.environ:
30
+ if 'VERCEL_IPC_PATH' in os.environ:
31
31
  from http.server import ThreadingHTTPServer
32
32
  import http
33
33
  import time
@@ -37,13 +37,8 @@ if 'VERCEL_IPC_FD' in os.environ or 'VERCEL_IPC_PATH' in os.environ:
37
37
  import logging
38
38
 
39
39
  start_time = time.time()
40
-
41
- if 'VERCEL_IPC_FD' in os.environ:
42
- ipc_fd = int(os.getenv("VERCEL_IPC_FD", ""))
43
- sock = socket.socket(fileno=ipc_fd)
44
- else:
45
- sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
46
- sock.connect(os.getenv("VERCEL_IPC_PATH", ""))
40
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
41
+ sock.connect(os.getenv("VERCEL_IPC_PATH", ""))
47
42
 
48
43
  send_message = lambda message: sock.sendall((json.dumps(message) + '\0').encode())
49
44
  storage = contextvars.ContextVar('storage', default=None)
@@ -183,6 +178,17 @@ if 'VERCEL_IPC_FD' in os.environ or 'VERCEL_IPC_PATH' in os.environ:
183
178
  del self.headers['x-vercel-internal-span-id']
184
179
  del self.headers['x-vercel-internal-trace-id']
185
180
 
181
+ send_message({
182
+ "type": "handler-started",
183
+ "payload": {
184
+ "handlerStartedAt": int(time.time() * 1000),
185
+ "context": {
186
+ "invocationId": invocationId,
187
+ "requestId": requestId,
188
+ }
189
+ }
190
+ })
191
+
186
192
  token = storage.set({
187
193
  "invocationId": invocationId,
188
194
  "requestId": requestId,